url
stringlengths 38
157
| content
stringlengths 72
15.1M
|
---|---|
https://redis.io/docs/latest/develop/data-types/sorted-sets/.html | <section class="prose w-full py-12">
<h1>
Redis sorted sets
</h1>
<p class="text-lg -mt-5 mb-10">
Introduction to Redis sorted sets
</p>
<p>
A Redis sorted set is a collection of unique strings (members) ordered by an associated score.
When more than one string has the same score, the strings are ordered lexicographically.
Some use cases for sorted sets include:
</p>
<ul>
<li>
Leaderboards. For example, you can use sorted sets to easily maintain ordered lists of the highest scores in a massive online game.
</li>
<li>
Rate limiters. In particular, you can use a sorted set to build a sliding-window rate limiter to prevent excessive API requests.
</li>
</ul>
<p>
You can think of sorted sets as a mix between a Set and
a Hash. Like sets, sorted sets are composed of unique, non-repeating
string elements, so in some sense a sorted set is a set as well.
</p>
<p>
However while elements inside sets are not ordered, every element in
a sorted set is associated with a floating point value, called
<em>
the score
</em>
(this is why the type is also similar to a hash, since every element
is mapped to a value).
</p>
<p>
Moreover, elements in a sorted set are
<em>
taken in order
</em>
(so they are not
ordered on request, order is a peculiarity of the data structure used to
represent sorted sets). They are ordered according to the following rule:
</p>
<ul>
<li>
If B and A are two elements with a different score, then A > B if A.score is > B.score.
</li>
<li>
If B and A have exactly the same score, then A > B if the A string is lexicographically greater than the B string. B and A strings can't be equal since sorted sets only have unique elements.
</li>
</ul>
<p>
Let's start with a simple example, we'll add all our racers and the score they got in the first race:
</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="ss_tutorial-stepzadd">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzadd" name="ss_tutorial-stepzadd" 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_ss_tutorial-stepzadd" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZADD racer_scores 10 "Norem"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZADD racer_scores 12 "Castilla"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZADD racer_scores 8 "Sam-Bodden" 10 "Royce" 6 "Ford" 14 "Prickett"
</span></span><span class="line hl"><span class="cl">(integer) 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_ss_tutorial-stepzadd')" 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_ss_tutorial-stepzadd" name="ss_tutorial-stepzadd" 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_ss_tutorial-stepzadd" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzadd" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</span><span class="p">:</span> <span class="mi">10</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"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzadd')" 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_ss_tutorial-stepzadd" 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_ss.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_ss_tutorial-stepzadd" name="ss_tutorial-stepzadd" 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_ss_tutorial-stepzadd" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzadd" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzadd')" 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_ss_tutorial-stepzadd" 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-ss.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_ss_tutorial-stepzadd" name="ss_tutorial-stepzadd" 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_ss_tutorial-stepzadd" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzadd" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzadd')" 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_ss_tutorial-stepzadd" 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/SortedSetsExample.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_ss_tutorial-stepzadd" name="ss_tutorial-stepzadd" 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_ss_tutorial-stepzadd" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzadd" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzadd')" 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_ss_tutorial-stepzadd" 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/ss_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_ss_tutorial-stepzadd" name="ss_tutorial-stepzadd" 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_ss_tutorial-stepzadd" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="m">10</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">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</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">// >>> True</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">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzadd')" 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_ss_tutorial-stepzadd" 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/SortedSetExample.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
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
is similar to
<a href="/docs/latest/commands/sadd/">
<code>
SADD
</code>
</a>
, but takes one additional argument
(placed before the element to be added) which is the score.
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
is also variadic, so you are free to specify multiple score-value
pairs, even if this is not used in the example above.
</p>
<p>
With sorted sets it is trivial to return a list of racers sorted by their
birth year because actually
<em>
they are already sorted
</em>
.
</p>
<p>
Implementation note: Sorted sets are implemented via a
dual-ported data structure containing both a skip list and a hash table, so
every time we add an element Redis performs an O(log(N)) operation. That's
good, so when we ask for sorted elements, Redis does not have to do any work at
all, it's already sorted. Note that the
<a href="/docs/latest/commands/zrange/">
<code>
ZRANGE
</code>
</a>
order is low to high, while the
<a href="/docs/latest/commands/zrevrange/">
<code>
ZREVRANGE
</code>
</a>
order is high to low:
</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="ss_tutorial-stepzrange">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzrange" name="ss_tutorial-stepzrange" 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_ss_tutorial-stepzrange" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzrange" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZRANGE racer_scores 0 -1
</span></span><span class="line hl"><span class="cl">1) "Ford"
</span></span><span class="line hl"><span class="cl">2) "Sam-Bodden"
</span></span><span class="line hl"><span class="cl">3) "Norem"
</span></span><span class="line hl"><span class="cl">4) "Royce"
</span></span><span class="line hl"><span class="cl">5) "Castilla"
</span></span><span class="line hl"><span class="cl">6) "Prickett"
</span></span><span class="line hl"><span class="cl">> ZREVRANGE racer_scores 0 -1
</span></span><span class="line hl"><span class="cl">1) "Prickett"
</span></span><span class="line hl"><span class="cl">2) "Castilla"
</span></span><span class="line hl"><span class="cl">3) "Royce"
</span></span><span class="line hl"><span class="cl">4) "Norem"
</span></span><span class="line hl"><span class="cl">5) "Sam-Bodden"
</span></span><span class="line hl"><span class="cl">6) "Ford"</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_ss_tutorial-stepzrange')" 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_ss_tutorial-stepzrange" name="ss_tutorial-stepzrange" 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_ss_tutorial-stepzrange" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzrange" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</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">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</span></span><span class="line hl"><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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzrange')" 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_ss_tutorial-stepzrange" 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_ss.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_ss_tutorial-stepzrange" name="ss_tutorial-stepzrange" 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_ss_tutorial-stepzrange" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzrange" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzrange')" 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_ss_tutorial-stepzrange" 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-ss.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_ss_tutorial-stepzrange" name="ss_tutorial-stepzrange" 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_ss_tutorial-stepzrange" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzrange" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 4
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</span></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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzrange')" 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_ss_tutorial-stepzrange" 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/SortedSetsExample.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_ss_tutorial-stepzrange" name="ss_tutorial-stepzrange" 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_ss_tutorial-stepzrange" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzrange" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></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">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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzrange')" 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_ss_tutorial-stepzrange" 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/ss_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_ss_tutorial-stepzrange" name="ss_tutorial-stepzrange" 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_ss_tutorial-stepzrange" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzrange" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 4</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzrange')" 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_ss_tutorial-stepzrange" 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/SortedSetExample.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: 0 and -1 means from element index 0 to the last element (-1 works
here just as it does in the case of the
<a href="/docs/latest/commands/lrange/">
<code>
LRANGE
</code>
</a>
command).
</p>
<p>
It is possible to return scores as well, using the
<code>
WITHSCORES
</code>
argument:
</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="ss_tutorial-stepzrange_withscores">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzrange_withscores" name="ss_tutorial-stepzrange_withscores" 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_ss_tutorial-stepzrange_withscores" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange_withscores" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzrange_withscores" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZRANGE racer_scores 0 -1 withscores
</span></span><span class="line hl"><span class="cl"> 1) "Ford"
</span></span><span class="line hl"><span class="cl"> 2) "6"
</span></span><span class="line hl"><span class="cl"> 3) "Sam-Bodden"
</span></span><span class="line hl"><span class="cl"> 4) "8"
</span></span><span class="line hl"><span class="cl"> 5) "Norem"
</span></span><span class="line hl"><span class="cl"> 6) "10"
</span></span><span class="line hl"><span class="cl"> 7) "Royce"
</span></span><span class="line hl"><span class="cl"> 8) "10"
</span></span><span class="line hl"><span class="cl"> 9) "Castilla"
</span></span><span class="line hl"><span class="cl">10) "12"
</span></span><span class="line hl"><span class="cl">11) "Prickett"
</span></span><span class="line hl"><span class="cl">12) "14"</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_ss_tutorial-stepzrange_withscores')" 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_ss_tutorial-stepzrange_withscores" name="ss_tutorial-stepzrange_withscores" 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_ss_tutorial-stepzrange_withscores" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange_withscores" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzrange_withscores" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</span>
</span></span><span class="line"><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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line hl"><span class="cl"> <span class="n">res6</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="c1"># >>> [</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.0)</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">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzrange_withscores')" 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_ss_tutorial-stepzrange_withscores" 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_ss.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_ss_tutorial-stepzrange_withscores" name="ss_tutorial-stepzrange_withscores" 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_ss_tutorial-stepzrange_withscores" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange_withscores" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzrange_withscores" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</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">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line hl"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line hl"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line hl"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzrange_withscores')" 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_ss_tutorial-stepzrange_withscores" 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-ss.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_ss_tutorial-stepzrange_withscores" name="ss_tutorial-stepzrange_withscores" 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_ss_tutorial-stepzrange_withscores" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange_withscores" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzrange_withscores" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzrange_withscores')" 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_ss_tutorial-stepzrange_withscores" 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/SortedSetsExample.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_ss_tutorial-stepzrange_withscores" name="ss_tutorial-stepzrange_withscores" 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_ss_tutorial-stepzrange_withscores" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange_withscores" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzrange_withscores" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></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">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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzrange_withscores')" 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_ss_tutorial-stepzrange_withscores" 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/ss_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_ss_tutorial-stepzrange_withscores" name="ss_tutorial-stepzrange_withscores" 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_ss_tutorial-stepzrange_withscores" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrange_withscores" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzrange_withscores" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzrange_withscores')" 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_ss_tutorial-stepzrange_withscores" 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/SortedSetExample.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>
<h3 id="operating-on-ranges">
Operating on ranges
</h3>
<p>
Sorted sets are more powerful than this. They can operate on ranges.
Let's get all the racers with 10 or fewer points. We
use the
<a href="/docs/latest/commands/zrangebyscore/">
<code>
ZRANGEBYSCORE
</code>
</a>
command to do it:
</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="ss_tutorial-stepzrangebyscore">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzrangebyscore" name="ss_tutorial-stepzrangebyscore" 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_ss_tutorial-stepzrangebyscore" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzrangebyscore" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZRANGEBYSCORE racer_scores -inf 10
</span></span><span class="line hl"><span class="cl">1) "Ford"
</span></span><span class="line hl"><span class="cl">2) "Sam-Bodden"
</span></span><span class="line hl"><span class="cl">3) "Norem"
</span></span><span class="line hl"><span class="cl">4) "Royce"</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_ss_tutorial-stepzrangebyscore')" 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_ss_tutorial-stepzrangebyscore" name="ss_tutorial-stepzrangebyscore" 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_ss_tutorial-stepzrangebyscore" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzrangebyscore" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">10</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"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzrangebyscore')" 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_ss_tutorial-stepzrangebyscore" 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_ss.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_ss_tutorial-stepzrangebyscore" name="ss_tutorial-stepzrangebyscore" 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_ss_tutorial-stepzrangebyscore" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzrangebyscore" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">10</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">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzrangebyscore')" 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_ss_tutorial-stepzrangebyscore" 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-ss.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_ss_tutorial-stepzrangebyscore" name="ss_tutorial-stepzrangebyscore" 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_ss_tutorial-stepzrangebyscore" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzrangebyscore" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.0]]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzrangebyscore')" 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_ss_tutorial-stepzrangebyscore" 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/SortedSetsExample.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_ss_tutorial-stepzrangebyscore" name="ss_tutorial-stepzrangebyscore" 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_ss_tutorial-stepzrangebyscore" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzrangebyscore" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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></span><span class="line hl"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzrangebyscore')" 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_ss_tutorial-stepzrangebyscore" 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/ss_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_ss_tutorial-stepzrangebyscore" name="ss_tutorial-stepzrangebyscore" 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_ss_tutorial-stepzrangebyscore" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzrangebyscore" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">10</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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzrangebyscore')" 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_ss_tutorial-stepzrangebyscore" 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/SortedSetExample.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 asked Redis to return all the elements with a score between negative
infinity and 10 (both extremes are included).
</p>
<p>
To remove an element we'd simply call
<a href="/docs/latest/commands/zrem/">
<code>
ZREM
</code>
</a>
with the racer's name.
It's also possible to remove ranges of elements. Let's remove racer Castilla along with all
the racers with strictly fewer than 10 points:
</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="ss_tutorial-stepzremrangebyscore">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzremrangebyscore" name="ss_tutorial-stepzremrangebyscore" 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_ss_tutorial-stepzremrangebyscore" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzremrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzremrangebyscore" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZREM racer_scores "Castilla"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZREMRANGEBYSCORE racer_scores -inf 9
</span></span><span class="line hl"><span class="cl">(integer) 2
</span></span><span class="line hl"><span class="cl">> ZRANGE racer_scores 0 -1
</span></span><span class="line hl"><span class="cl">1) "Norem"
</span></span><span class="line hl"><span class="cl">2) "Royce"
</span></span><span class="line hl"><span class="cl">3) "Prickett"</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_ss_tutorial-stepzremrangebyscore')" 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_ss_tutorial-stepzremrangebyscore" name="ss_tutorial-stepzremrangebyscore" 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_ss_tutorial-stepzremrangebyscore" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzremrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzremrangebyscore" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</span>
</span></span><span class="line"><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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</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"># >>> 1</span>
</span></span><span class="line hl"><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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzremrangebyscore')" 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_ss_tutorial-stepzremrangebyscore" 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_ss.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_ss_tutorial-stepzremrangebyscore" name="ss_tutorial-stepzremrangebyscore" 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_ss_tutorial-stepzremrangebyscore" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzremrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzremrangebyscore" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</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">// >>> 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 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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzremrangebyscore')" 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_ss_tutorial-stepzremrangebyscore" 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-ss.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_ss_tutorial-stepzremrangebyscore" name="ss_tutorial-stepzremrangebyscore" 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_ss_tutorial-stepzremrangebyscore" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzremrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzremrangebyscore" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzremrangebyscore')" 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_ss_tutorial-stepzremrangebyscore" 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/SortedSetsExample.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_ss_tutorial-stepzremrangebyscore" name="ss_tutorial-stepzremrangebyscore" 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_ss_tutorial-stepzremrangebyscore" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzremrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzremrangebyscore" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzremrangebyscore')" 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_ss_tutorial-stepzremrangebyscore" 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/ss_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_ss_tutorial-stepzremrangebyscore" name="ss_tutorial-stepzremrangebyscore" 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_ss_tutorial-stepzremrangebyscore" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzremrangebyscore" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzremrangebyscore" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</span>
</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</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">// >>> True</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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzremrangebyscore')" 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_ss_tutorial-stepzremrangebyscore" 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/SortedSetExample.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>
<a href="/docs/latest/commands/zremrangebyscore/">
<code>
ZREMRANGEBYSCORE
</code>
</a>
is perhaps not the best command name,
but it can be very useful, and returns the number of removed elements.
</p>
<p>
Another extremely useful operation defined for sorted set elements
is the get-rank operation. It is possible to ask what is the
position of an element in the set of ordered elements.
The
<a href="/docs/latest/commands/zrevrank/">
<code>
ZREVRANK
</code>
</a>
command is also available in order to get the rank, considering
the elements sorted in a descending way.
</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="ss_tutorial-stepzrank">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzrank" name="ss_tutorial-stepzrank" 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_ss_tutorial-stepzrank" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrank" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzrank" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZRANK racer_scores "Norem"
</span></span><span class="line hl"><span class="cl">(integer) 0
</span></span><span class="line hl"><span class="cl">> ZREVRANK racer_scores "Norem"
</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_ss_tutorial-stepzrank')" 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_ss_tutorial-stepzrank" name="ss_tutorial-stepzrank" 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_ss_tutorial-stepzrank" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrank" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzrank" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzrank')" 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_ss_tutorial-stepzrank" 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_ss.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_ss_tutorial-stepzrank" name="ss_tutorial-stepzrank" 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_ss_tutorial-stepzrank" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrank" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzrank" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzrank')" 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_ss_tutorial-stepzrank" 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-ss.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_ss_tutorial-stepzrank" name="ss_tutorial-stepzrank" 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_ss_tutorial-stepzrank" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrank" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzrank" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzrank')" 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_ss_tutorial-stepzrank" 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/SortedSetsExample.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_ss_tutorial-stepzrank" name="ss_tutorial-stepzrank" 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_ss_tutorial-stepzrank" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrank" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzrank" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzrank')" 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_ss_tutorial-stepzrank" 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/ss_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_ss_tutorial-stepzrank" name="ss_tutorial-stepzrank" 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_ss_tutorial-stepzrank" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzrank" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzrank" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</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">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzrank')" 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_ss_tutorial-stepzrank" 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/SortedSetExample.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>
<h3 id="lexicographical-scores">
Lexicographical scores
</h3>
<p>
In version Redis 2.8, a new feature was introduced that allows
getting ranges lexicographically, assuming elements in a sorted set are all
inserted with the same identical score (elements are compared with the C
<code>
memcmp
</code>
function, so it is guaranteed that there is no collation, and every
Redis instance will reply with the same output).
</p>
<p>
The main commands to operate with lexicographical ranges are
<a href="/docs/latest/commands/zrangebylex/">
<code>
ZRANGEBYLEX
</code>
</a>
,
<a href="/docs/latest/commands/zrevrangebylex/">
<code>
ZREVRANGEBYLEX
</code>
</a>
,
<a href="/docs/latest/commands/zremrangebylex/">
<code>
ZREMRANGEBYLEX
</code>
</a>
and
<a href="/docs/latest/commands/zlexcount/">
<code>
ZLEXCOUNT
</code>
</a>
.
</p>
<p>
For example, let's add again our list of famous racers, but this time
using a score of zero for all the elements. We'll see that because of the sorted sets ordering rules, they are already sorted lexicographically. Using
<a href="/docs/latest/commands/zrangebylex/">
<code>
ZRANGEBYLEX
</code>
</a>
we can ask for lexicographical ranges:
</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="ss_tutorial-stepzadd_lex">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepzadd_lex" name="ss_tutorial-stepzadd_lex" 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_ss_tutorial-stepzadd_lex" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd_lex" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepzadd_lex" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZADD racer_scores 0 "Norem" 0 "Sam-Bodden" 0 "Royce" 0 "Castilla" 0 "Prickett" 0 "Ford"
</span></span><span class="line hl"><span class="cl">(integer) 3
</span></span><span class="line hl"><span class="cl">> ZRANGE racer_scores 0 -1
</span></span><span class="line hl"><span class="cl">1) "Castilla"
</span></span><span class="line hl"><span class="cl">2) "Ford"
</span></span><span class="line hl"><span class="cl">3) "Norem"
</span></span><span class="line hl"><span class="cl">4) "Prickett"
</span></span><span class="line hl"><span class="cl">5) "Royce"
</span></span><span class="line hl"><span class="cl">6) "Sam-Bodden"
</span></span><span class="line hl"><span class="cl">> ZRANGEBYLEX racer_scores [A [L
</span></span><span class="line hl"><span class="cl">1) "Castilla"
</span></span><span class="line hl"><span class="cl">2) "Ford"</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_ss_tutorial-stepzadd_lex')" 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_ss_tutorial-stepzadd_lex" name="ss_tutorial-stepzadd_lex" 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_ss_tutorial-stepzadd_lex" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd_lex" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepzadd_lex" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 2</span>
</span></span><span class="line"><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">zadd</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"racer_scores"</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="s2">"Norem"</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="s2">"Sam-Bodden"</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="s2">"Royce"</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="s2">"Ford"</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="s2">"Prickett"</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="s2">"Castilla"</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="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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</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"># >>> ['Castilla', 'Ford']</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</span><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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</span><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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</span><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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</span><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"># >>> 200.0</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_Python_ss_tutorial-stepzadd_lex')" 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_ss_tutorial-stepzadd_lex" 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_ss.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_ss_tutorial-stepzadd_lex" name="ss_tutorial-stepzadd_lex" 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_ss_tutorial-stepzadd_lex" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd_lex" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepzadd_lex" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 2
</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">res13</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</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">res13</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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</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">// >>> ['Castilla', 'Ford']
</span></span></span><span class="line"><span 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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.0
</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_ss_tutorial-stepzadd_lex')" 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_ss_tutorial-stepzadd_lex" 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-ss.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_ss_tutorial-stepzadd_lex" name="ss_tutorial-stepzadd_lex" 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_ss_tutorial-stepzadd_lex" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd_lex" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepzadd_lex" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 2
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</span></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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</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">// >>> [Castilla, Ford]
</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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 200.0
</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 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_ss_tutorial-stepzadd_lex')" 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_ss_tutorial-stepzadd_lex" 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/SortedSetsExample.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_ss_tutorial-stepzadd_lex" name="ss_tutorial-stepzadd_lex" 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_ss_tutorial-stepzadd_lex" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd_lex" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepzadd_lex" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</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="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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line hl"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</span></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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 150
</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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 200
</span></span></span><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_ss_tutorial-stepzadd_lex')" 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_ss_tutorial-stepzadd_lex" 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/ss_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_ss_tutorial-stepzadd_lex" name="ss_tutorial-stepzadd_lex" 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_ss_tutorial-stepzadd_lex" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepzadd_lex" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepzadd_lex" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 2</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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</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">// >>> Castilla, Ford</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 150.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 200.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></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_ss_tutorial-stepzadd_lex')" 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_ss_tutorial-stepzadd_lex" 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/SortedSetExample.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>
Ranges can be inclusive or exclusive (depending on the first character),
also string infinite and minus infinite are specified respectively with
the
<code>
+
</code>
and
<code>
-
</code>
strings. See the documentation for more information.
</p>
<p>
This feature is important because it allows us to use sorted sets as a generic
index. For example, if you want to index elements by a 128-bit unsigned
integer argument, all you need to do is to add elements into a sorted
set with the same score (for example 0) but with a 16 byte prefix
consisting of
<strong>
the 128 bit number in big endian
</strong>
. Since numbers in big
endian, when ordered lexicographically (in raw bytes order) are actually
ordered numerically as well, you can ask for ranges in the 128 bit space,
and get the element's value discarding the prefix
</p>
<h2 id="updating-the-score-leaderboards">
Updating the score: leaderboards
</h2>
<p>
Just a final note about sorted sets before switching to the next topic.
Sorted sets' scores can be updated at any time. Just calling
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
against
an element already included in the sorted set will update its score
(and position) with O(log(N)) time complexity. As such, sorted sets are suitable
when there are tons of updates.
</p>
<p>
Because of this characteristic a common use case is leaderboards.
The typical application is a Facebook game where you combine the ability to
take users sorted by their high score, plus the get-rank operation, in order
to show the top-N users, and the user rank in the leader board (e.g., "you are
the #4932 best score here").
</p>
<h2 id="examples">
Examples
</h2>
<ul>
<li>
There are two ways we can use a sorted set to represent a leaderboard. If we know a racer's new score, we can update it directly via the
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
command. However, if we want to add points to an existing score, we can use the
<a href="/docs/latest/commands/zincrby/">
<code>
ZINCRBY
</code>
</a>
command.
<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="ss_tutorial-stepleaderboard">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_ss_tutorial-stepleaderboard" name="ss_tutorial-stepleaderboard" 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_ss_tutorial-stepleaderboard" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-ss_tutorial-stepleaderboard" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_ss_tutorial-stepleaderboard" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZADD racer_scores 100 "Wood"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZADD racer_scores 100 "Henshaw"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZADD racer_scores 150 "Henshaw"
</span></span><span class="line hl"><span class="cl">(integer) 0
</span></span><span class="line hl"><span class="cl">> ZINCRBY racer_scores 50 "Wood"
</span></span><span class="line hl"><span class="cl">"150"
</span></span><span class="line hl"><span class="cl">> ZINCRBY racer_scores 50 "Henshaw"
</span></span><span class="line hl"><span class="cl">"200"</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_ss_tutorial-stepleaderboard')" 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_ss_tutorial-stepleaderboard" name="ss_tutorial-stepleaderboard" 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_ss_tutorial-stepleaderboard" title="Open example">
Python
</label>
<div aria-labelledby="tab-ss_tutorial-stepleaderboard" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_ss_tutorial-stepleaderboard" 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 Sorted set doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/sorted-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></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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Norem"</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">res1</span><span class="p">)</span> <span class="c1"># >>> 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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><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"># >>> 1</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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">12</span><span 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="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># >>> 4</span>
</span></span><span class="line"><span class="cl">
</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']</span>
</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">zrevrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span> <span class="c1"># >>> ['Prickett', 'Castilla', 'Royce', 'Norem', 'Sam-Bodden', 'Ford']</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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="n">withscores</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></span><span class="line"><span class="cl"> <span class="n">res6</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Ford', 6.0), ('Sam-Bodden', 8.0), ('Norem', 10.0), ('Royce', 10.0),</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ('Castilla', 12.0), ('Prickett', 14.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="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</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">res7</span><span class="p">)</span> <span class="c1"># >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']</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">zrem</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Castilla"</span><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"># >>> 1</span>
</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">zremrangebyscore</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"-inf"</span><span class="p">,</span> <span class="mi">9</span><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"># >>> 2</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span> <span class="c1"># >>> ['Norem', 'Royce', 'Prickett']</span>
</span></span><span 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">zrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 0</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">zrevrank</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"Norem"</span><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"># >>> 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">zadd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"racer_scores"</span><span 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="s2">"Norem"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Sam-Bodden"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Royce"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Ford"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Prickett"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Castilla"</span><span class="p">:</span> <span class="mi">0</span><span 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="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># >>> 3</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">zrange</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</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"># >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']</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">zrangebylex</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="s2">"[A"</span><span class="p">,</span> <span class="s2">"[L"</span><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"># >>> ['Castilla', 'Ford']</span>
</span></span><span class="line"><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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Wood"</span><span class="p">:</span> <span class="mi">100</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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">100</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"># >>> 1</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">zadd</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"Henshaw"</span><span class="p">:</span> <span class="mi">150</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"># >>> 0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Wood"</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"># >>> 150.0</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">zincrby</span><span class="p">(</span><span class="s2">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s2">"Henshaw"</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"># >>> 200.0</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_Python_ss_tutorial-stepleaderboard')" 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_ss_tutorial-stepleaderboard" 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_ss.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_ss_tutorial-stepleaderboard" name="ss_tutorial-stepleaderboard" 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_ss_tutorial-stepleaderboard" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-ss_tutorial-stepleaderboard" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_ss_tutorial-stepleaderboard" 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="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></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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">});</span>
</span></span><span class="line"><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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span class="p">});</span>
</span></span><span class="line"><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">// >>> 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">res3</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">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">8</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">14</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">12</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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></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">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res4</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce', 'Castilla', 'Prickett']
</span></span></span><span class="line"><span 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">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> [
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Ford', score: 6 }, { value: 'Sam-Bodden', score: 8 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Norem', score: 10 }, { value: 'Royce', score: 10 },
</span></span></span><span class="line"><span class="cl"><span class="c1">// { value: 'Castilla', score: 12 }, { value: 'Prickett', score: 14 }
</span></span></span><span class="line"><span class="cl"><span class="c1">// ]
</span></span></span><span class="line"><span 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">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</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">res7</span><span class="p">);</span> <span class="c1">// >>> ['Ford', 'Sam-Bodden', 'Norem', 'Royce']
</span></span></span><span class="line"><span 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRem</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Castilla'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRemRangeByScore</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'-inf'</span><span class="p">,</span> <span class="mi">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">res10</span><span class="p">);</span> <span class="c1">// >>> ['Norem', 'Royce', 'Prickett']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><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">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">zRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRevRank</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'Norem'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">zAdd</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Norem'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Sam-Bodden'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Royce'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Ford'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Prickett'</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Castilla'</span> <span 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">res13</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">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</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">// >>> ['Castilla', 'Ford', 'Norem', 'Prickett', 'Royce', 'Sam-Bodden']
</span></span></span><span class="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">zRangeByLex</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="s1">'[A'</span><span class="p">,</span> <span class="s1">'[L'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> ['Castilla', 'Ford']
</span></span></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">res16</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Wood'</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">// >>> 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">res17</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</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">// >>> 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">res18</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">'racer_scores'</span><span class="p">,</span> <span class="p">{</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">150</span><span class="p">,</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'Henshaw'</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">nx</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="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">// >>> 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">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Wood'</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">// >>> 150.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">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zIncrBy</span><span class="p">(</span><span class="s1">'racer_scores'</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s1">'Henshaw'</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">// >>> 200.0
</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_ss_tutorial-stepleaderboard')" 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_ss_tutorial-stepleaderboard" 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-ss.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_ss_tutorial-stepleaderboard" name="ss_tutorial-stepleaderboard" 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_ss_tutorial-stepleaderboard" title="Open example">
Java
</label>
<div aria-labelledby="tab-ss_tutorial-stepleaderboard" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_ss_tutorial-stepleaderboard" 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">redis.clients.jedis.resps.Tuple</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="kd">public</span> <span class="kd">class</span> <span class="nc">SortedSetsExample</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></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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">8d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">6d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mi">14</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mi">12</span><span class="n">d</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="n">System</span><span 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">// >>> 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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res4</span><span class="o">);</span> <span class="c1">// >>> [Ford, Sam-Bodden, Norem, Royce, Castil, Castilla, Prickett]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res5</span><span class="o">);</span> <span class="c1">// >>> [Prickett, Castilla, Castil, Royce, Norem, Sam-Bodden, Ford]
</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"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"racer_scores"</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">res6</span><span class="o">);</span> <span class="c1">// >>> [[Ford,6.0], [Sam-Bodden,8.0], [Norem,10.0], [Royce,10.0], [Castil,12.0], [Castilla,12.0], [Prickett,14.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">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mi">10</span><span class="n">d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Ford, Sam-Bodden, Norem, Royce]
</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">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrem</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Castilla"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zremrangeByScore</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="n">Double</span><span class="o">.</span><span class="na">MIN_VALUE</span><span class="o">,</span> <span class="mf">9d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">res10</span><span class="o">);</span> <span class="c1">// >>> [Norem, Royce, Prickett]
</span></span></span><span class="line"><span 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">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrevrank</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"Norem"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 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">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><</span><span class="n">String</span><span class="o">,</span><span class="n">Double</span><span class="o">>()</span> <span class="o">{{</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Norem"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Sam-Bodden"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Royce"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Ford"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Prickett"</span><span class="o">,</span> <span class="mf">0d</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">put</span><span class="o">(</span><span class="s">"Castilla"</span><span class="o">,</span> <span class="mf">0d</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="n">System</span><span 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">// >>> 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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"racer_scores"</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">// >>> [Castilla, Ford, Norem, Prickett, Royce, Sam-Bodden]
</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"><</span><span class="n">String</span><span class="o">></span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByLex</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="s">"[A"</span><span class="o">,</span> <span class="s">"[L"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> [Castilla, Ford]
</span></span></span><span class="line"><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">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</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">// >>> 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">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</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">// >>> 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">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">100</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</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">// >>> 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">double</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Wood"</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">// >>> 150.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">double</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zincrby</span><span class="o">(</span><span class="s">"racer_scores"</span><span class="o">,</span> <span class="mi">50</span><span class="n">d</span><span class="o">,</span> <span class="s">"Henshaw"</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">// >>> 200.0
</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 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_ss_tutorial-stepleaderboard')" 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_ss_tutorial-stepleaderboard" 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/SortedSetsExample.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_ss_tutorial-stepleaderboard" name="ss_tutorial-stepleaderboard" 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_ss_tutorial-stepleaderboard" title="Open example">
Go
</label>
<div aria-labelledby="tab-ss_tutorial-stepleaderboard" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_ss_tutorial-stepleaderboard" 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_zadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">10</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 4
</span></span></span><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_zrange</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce Castilla Prickett]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">ZRevRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res5</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Prickett Castilla Royce Norem Sam-Bodden Ford]
</span></span></span><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_zrangewithscores</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</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">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res6</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [{6 Ford} {8 Sam-Bodden} {10 Norem} {10 Royce} {12 Castilla} {14 Prickett}]
</span></span></span><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_zrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span><span class="nx">Min</span><span class="p">:</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"10"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Ford Sam-Bodden Norem Royce]
</span></span></span><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_zremrangebyscore</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">8</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">6</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">12</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRem</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRemRangeByScore</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"-inf"</span><span class="p">,</span> <span class="s">"9"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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">res10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> [Norem Royce Prickett]
</span></span></span><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_zrank</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">14</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="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">ZRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRevRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_zaddlex</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Ford"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="nx">Score</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">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</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></span><span class="line"><span class="cl"> <span class="c1">// >>> [Castilla Ford Norem Prickett Royce Sam-Bodden]
</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">ZRangeByLex</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeBy</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Min</span><span class="p">:</span> <span class="s">"[A"</span><span class="p">,</span> <span class="nx">Max</span><span class="p">:</span> <span class="s">"[L"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">}).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> [Castilla Ford]
</span></span></span><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_leaderboard</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">100</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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">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">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">150</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> 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">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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Wood"</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">// >>> 150
</span></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">ZIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_scores"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="s">"Henshaw"</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">// >>> 200
</span></span></span><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_ss_tutorial-stepleaderboard')" 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_ss_tutorial-stepleaderboard" 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/ss_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_ss_tutorial-stepleaderboard" name="ss_tutorial-stepleaderboard" 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_ss_tutorial-stepleaderboard" title="Open example">
C#
</label>
<div aria-labelledby="tab-ss_tutorial-stepleaderboard" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_ss_tutorial-stepleaderboard" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><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 class="k">public</span> <span class="k">class</span> <span class="nc">SortedSetExample</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 class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</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">res1</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">8</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">10</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">6</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">14</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">12</span><span 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">res3</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res4</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce, Castilla, Prickett</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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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 class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="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">res5</span><span class="p">));</span> <span class="c1">// >>> Prickett, Castilla, Royce, Norem, Sam-Bodden, Ford</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"racer_scores"</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">res6</span><span class="p">));</span> <span class="c1">// >>> Ford: 6, Sam-Bodden: 8, Norem: 10, Royce: 10, Castilla: 12, Prickett: 14</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">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</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="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">res7</span><span class="p">));</span> <span class="c1">// >>> Ford, Sam-Bodden, Norem, Royce</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">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemove</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRemoveRangeByScore</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="kt">double</span><span class="p">.</span><span class="n">NegativeInfinity</span><span class="p">,</span> <span class="m">9</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">res10</span><span class="p">));</span> <span class="c1">// >>> Norem, Royce, Prickett</span>
</span></span><span 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">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRank</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">,</span> <span class="n">Order</span><span class="p">.</span><span class="n">Descending</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// >>> 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">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="k">new</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Norem"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Sam-Bodden"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Royce"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Ford"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Prickett"</span><span class="p">,</span> <span class="m">0</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"Castilla"</span><span class="p">,</span> <span class="m">0</span><span 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">res13</span><span class="p">);</span> <span class="c1">// >>> 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">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"racer_scores"</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">// >>> Castilla, Ford, Norem, Pricket, Royce, Sam-Bodden</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">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByValue</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"A"</span><span class="p">,</span> <span class="s">"L"</span><span class="p">,</span> <span class="n">Exclude</span><span class="p">.</span><span class="n">None</span><span class="p">);</span>
</span></span><span class="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">// >>> Castilla, Ford</span>
</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">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">100</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">// >>> 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">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">100</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">// >>> 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">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">150</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">res18</span><span class="p">);</span> <span class="c1">// >>> False</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">double</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Wood"</span><span class="p">,</span> <span class="m">50</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">// >>> 150.0</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">double</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetIncrement</span><span class="p">(</span><span class="s">"racer_scores"</span><span class="p">,</span> <span class="s">"Henshaw"</span><span class="p">,</span> <span class="m">50</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">// >>> 200.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></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_ss_tutorial-stepleaderboard')" 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_ss_tutorial-stepleaderboard" 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/SortedSetExample.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>
</li>
</ul>
<p>
You'll see that
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
returns 0 when the member already exists (the score is updated), while
<a href="/docs/latest/commands/zincrby/">
<code>
ZINCRBY
</code>
</a>
returns the new score. The score for racer Henshaw went from 100, was changed to 150 with no regard for what score was there before, and then was incremented by 50 to 200.
</p>
<h2 id="basic-commands">
Basic commands
</h2>
<ul>
<li>
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
adds a new member and associated score to a sorted set. If the member already exists, the score is updated.
</li>
<li>
<a href="/docs/latest/commands/zrange/">
<code>
ZRANGE
</code>
</a>
returns members of a sorted set, sorted within a given range.
</li>
<li>
<a href="/docs/latest/commands/zrank/">
<code>
ZRANK
</code>
</a>
returns the rank of the provided member, assuming the sorted is in ascending order.
</li>
<li>
<a href="/docs/latest/commands/zrevrank/">
<code>
ZREVRANK
</code>
</a>
returns the rank of the provided member, assuming the sorted set is in descending order.
</li>
</ul>
<p>
See the
<a href="/docs/latest/commands/?group=sorted-set">
complete list of sorted set commands
</a>
.
</p>
<h2 id="performance">
Performance
</h2>
<p>
Most sorted set operations are O(log(n)), where
<em>
n
</em>
is the number of members.
</p>
<p>
Exercise some caution when running the
<a href="/docs/latest/commands/zrange/">
<code>
ZRANGE
</code>
</a>
command with large returns values (e.g., in the tens of thousands or more).
This command's time complexity is O(log(n) + m), where
<em>
m
</em>
is the number of results returned.
</p>
<h2 id="alternatives">
Alternatives
</h2>
<p>
Redis sorted sets are sometimes used for indexing other Redis data structures.
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=MUKlxdBQZ7g">
Redis Sorted Sets Explained
</a>
is an entertaining introduction to sorted sets in Redis.
</li>
<li>
<a href="https://university.redis.com/courses/ru101/">
Redis University's RU101
</a>
explores Redis sorted 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/sorted-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/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes 7.2.4-12 (Dec 2023) release notes
</h1>
<p class="text-lg -mt-5 mb-10">
This is a maintenance release with a few enhancements/fixes on the Kubernetes product and a new Redis Enterprise container version.
</p>
<h2 id="highlights">
Highlights
</h2>
<p>
This is a maintenance release with a few enhancements/fixes on the Kubernetes product and a newer Redis Enterprise container version.
</p>
<h2 id="new-in-this-release">
New in this release
</h2>
<h3 id="enhancements">
Enhancements
</h3>
<ul>
<li>
Added to
<a href="#supported-distributions">
supported distributions
</a>
</li>
<li>
Added support for Redis Enterprise Software 7.2.4-92 (RED-113750)
</li>
<li>
Replaced usage of config maps for readiness check and prestop scripts of Redis Enterprise pods (RED-81443)
</li>
</ul>
<h3 id="resolved-issues">
Resolved issues
</h3>
<ul>
<li>
Fixed issues around REC creation when namespace contains old resources from previous installation (RED-100669) (RED-100668)
</li>
<li>
Fixed constant updates to watched namespaces REDB services (RED-103264)
</li>
<li>
Fixed labeling of old operator configmaps (RED-105517)
</li>
<li>
Removed automatic upgrades of modules during upgrades (RED-106834)
</li>
<li>
Fixed unexpected restart of container during cluster recovery (RED-108511)
</li>
<li>
Fixed timeout of prestop (RED-111471)
</li>
<li>
Fixed deployment issues on TKG (RED-111271)
</li>
</ul>
<h2 id="version-changes">
Version changes
</h2>
<p>
For a list of fixes related to CVEs, see the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-92/#security">
Redis Enterprise 7.2.4-92 release notes
</a>
.
</p>
<h3 id="breaking-changes">
Breaking changes
</h3>
<p>
The following changes included in this release affect the upgrade process. Please read carefully before upgrading to 7.2.4-12.
</p>
<h4 id="upgrade-operating-system">
Upgrade operating system
</h4>
<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>
If your databases use modules, you need to update all nodes in the cluster to Redis Enterprise 7.2.4 or later before upgrading your operating system. See
<a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-os/">
Upgrade a cluster's operating system
</a>
in the Redis Enterprise Software documentation for more details.
</div>
</div>
<h4 id="terminationgraceperiodseconds">
terminationGracePeriodSeconds
</h4>
<p>
The configurable
<code>
terminationGracePeriodSeconds
</code>
REC field has been added to replace the hard-coded timeout of 15 minutes for a node to be stopped/drained (RED-111471).
</p>
<h4 id="validatingwebhookconfiguration">
ValidatingWebhookConfiguration
</h4>
<p>
Versions 6.4.2-4 and later include a new
<code>
ValidatingWebhookConfiguration
</code>
resource to replace the
<code>
redb-admission
</code>
webhook resource. To use releases 6.4.2-4 or later, delete the old webhook resource and apply the new file. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#reapply-webhook">
upgrade Redis cluster
</a>
for instructions.
</p>
<h4 id="openshift-scc">
OpenShift SCC
</h4>
<p>
Versions 6.4.2-6 and later include a new SCC (
<code>
redis-enterprise-scc-v2
</code>
) that you need to bind to your service account before upgrading. OpenShift clusters running version 6.2.12 or earlier upgrading to version 6.2.18 or later might get stuck if you skip this step. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#before-upgrading">
upgrade a Redis Enterprise cluster (REC)
</a>
for instructions.
</p>
<h3 id="upcoming-changes">
Upcoming changes
</h3>
<ul>
<li>
A future release of Redis Enterprise will remove support for RHEL7. We recommend migrating to RHEL8.
</li>
</ul>
<h3 id="supported-distributions">
Supported distributions
</h3>
<p>
The following table shows supported distributions at the time of this release. You can also find this list in
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
.
</p>
<p>
<span title="Check mark icon">
✅
</span>
Supported – This distribution is supported for this version of Redis Enterprise Software for Kubernetes.
</p>
<p>
<span title="Warning icon">
⚠️
</span>
Deprecated – This distribution is still supported for this version of Redis Enterprise Software for Kubernetes, but support will be removed in a future release.
</p>
<p>
<span title="X icon">
❌
</span>
End of life – Support for this distribution ended.
</p>
<p>
Any distribution not listed below is not supported for production workloads.
</p>
<table>
<thead>
<tr>
<th>
<strong>
Kubernetes version
</strong>
</th>
<th>
<strong>
1.23
</strong>
</th>
<th>
<strong>
1.24
</strong>
</th>
<th>
<strong>
1.25
</strong>
</th>
<th>
<strong>
1.26
</strong>
</th>
<th>
<strong>
1.27
</strong>
</th>
<th>
<strong>
1.28
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Community Kubernetes
</td>
<td>
</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>
Amazon EKS
</td>
<td>
<span title="Deprecation warning">
⚠️
</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>
Azure AKS
</td>
<td>
</td>
<td>
</td>
<td>
<span title="Supported">
✅
</span>
</td>
<td>
<span title="Supported">
✅
</span>
</td>
<td>
<span title="Supported">
✅
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
Google GKE
</td>
<td>
<span title="X icon">
❌
</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>
Rancher 2.6
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
Rancher RKE2
</td>
<td>
<span title="Deprecation warning">
⚠️
</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>
VMware TKG 2.1
</td>
<td>
<span title="Deprecation warning">
⚠️
</span>
</td>
<td>
<span title="Supported">
✅
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
VMware TKG 2.2
</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>
</tr>
<tr>
<td>
VMware TKG 2.3
</td>
<td>
</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>
<strong>
OpenShift version
</strong>
</td>
<td>
<strong>
4.10
</strong>
</td>
<td>
<strong>
4.11
</strong>
</td>
<td>
<strong>
4.12
</strong>
</td>
<td>
<strong>
4.13
</strong>
</td>
<td>
<strong>
4.14
</strong>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span title="X icon">
❌
</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>
<strong>
VMware TKGI version
</strong>
</td>
<td>
<strong>
1.14
</strong>
</td>
<td>
<strong>
1.15
</strong>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Supported">
✅
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
<h2 id="downloads">
Downloads
</h2>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
redislabs/redis:7.2.4-92
</code>
</li>
<li>
<strong>
Operator
</strong>
:
<code>
redislabs/operator:7.2.4-12
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
redislabs/k8s-controller:7.2.4-12.
</code>
</li>
</ul>
<h4 id="openshift-images">
OpenShift images
</h4>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
registry.connect.redhat.com/redislabs/redis-enterprise:7.2.4-92.rhel8-openshift
</code>
(or
<code>
redislabs/redis-enterprise:7.2.4-92.rhel7-openshift
</code>
if upgrading from RHEL 7)
</li>
<li>
<strong>
Operator
</strong>
:
<code>
registry.connect.redhat.com/redislabs/redis-enterprise-operator:7.2.4-12
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
registry.connect.redhat.com/redislabs/services-manager:7.2.4-12
</code>
</li>
</ul>
<h4 id="olm-bundle">
OLM bundle
</h4>
<p>
<strong>
Redis Enterprise operator bundle
</strong>
:
<code>
v7.2.4-12
</code>
</p>
<h2 id="known-limitations">
Known limitations
</h2>
<p>
The limitations below are specific to the Redis Enterprise for Kubernetes product. To view limitations for the supported Redis Enterprise Software version, see the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/#known-limitations">
7.2.4 release notes
</a>
.
</p>
<h3 id="existing-limitations">
Existing limitations
</h3>
<ul>
<li>
<p>
<strong>
When modifying the database suffix for an Active-Active database, while the service-rigger is in a terminating state, the services-rigger will delete and create the ingress or route resources in a loop (RED-107687)
</strong>
Wait until the services- rigger pod has finished to terminate it.
</p>
</li>
<li>
<p>
<strong>
REAADB changes might fail with "gateway timeout" errors, mostly on OpenShift (RED-103048)
</strong>
Retry the operation.
</p>
</li>
<li>
<p>
<strong>
Creating two databases with the same name directly on Redis Enterprise software will cause the service to be deleted and the database will not be available (RED-99997)
</strong>
Avoid duplicating database names. Database creation via K8s has validation in place to prevent this.
</p>
</li>
<li>
<p>
<strong>
Installing the operator bundle produces warning:
<code>
Warning: would violate PodSecurity "restricted: v1.24"
</code>
(RED-97381)
</strong>
Ignore the warning. This issue is documented as benign on official Red Hat documentation.
</p>
</li>
<li>
<p>
<strong>
RERC resources must have a unique name (RED-96302)
</strong>
The string "rec-name"/"rec-namespace" must be different from all other participating clusters in the Active-Active database.
</p>
</li>
<li>
<p>
<strong>
Admission is not blocking REAADB with
<code>
shardCount
</code>
which exceeds license quota (RED-96301)
</strong>
Fix the problems with the REAADB and reapply.
</p>
</li>
<li>
<p>
<strong>
Active-Active controller only supports global database options. Configuration specific to location is not supported (RED-86490)
</strong>
</p>
</li>
<li>
<p>
<strong>
Active-Active setup removal might keep services or routes undeleted (RED-77752)
</strong>
Delete services or routes manually if you encounter this problem.
</p>
</li>
<li>
<p>
<strong>
<code>
autoUpgrade
</code>
set to
<code>
true
</code>
can cause unexpected bdb upgrades when
<code>
redisUpgradePolicy
</code>
is set to
<code>
true
</code>
(RED-72351)
</strong>
Contact support if your deployment is impacted.
</p>
</li>
<li>
<p>
<strong>
Following the previous quick start guide version causes issues with creating an REDB due to unrecognized memory field name (RED-69515)
</strong>
The workaround is to use the newer (current) revision of Deploy Redis Enterprise Software for Kubernetes.
</p>
</li>
<li>
<p>
<strong>
PVC size issues when using decimal value in spec (RED-62132)
</strong>
Make sure you use integer values for the PVC size.
</p>
</li>
<li>
<p>
<strong>
REC might report error states on initial startup (RED-61707)
</strong>
There is no workaround at this time except to ignore the errors.
</p>
</li>
<li>
<p>
<strong>
Hashicorp Vault integration - no support for Gesher (RED-55080)
</strong>
There is no workaround for this issue. Gesher support has been deprecated.
</p>
</li>
<li>
<p>
<strong>
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254)
</strong>
When REC clusters are deployed on Kubernetes clusters without synchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes.
</p>
</li>
<li>
<p>
<strong>
Deleting an OpenShift project with an REC deployed may hang (RED-47192)
</strong>
When an 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. Therefore, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Then, you can delete the project.
</p>
</li>
<li>
<p>
<strong>
Clusters must be named 'rec' in OLM-based deployments (RED-39825)
</strong>
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 (namely, "rec"). The workaround is to name the cluster "rec".
</p>
</li>
<li>
<p>
<strong>
Readiness probe incorrect on failures (RED-39300)
</strong>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on node failure.
</p>
</li>
<li>
<p>
<strong>
Internal DNS and Kubernetes DNS may have conflicts (RED-37462)
</strong>
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>
</li>
<li>
<p>
<strong>
K8s-based 5.4.10 clusters seem to negatively affect existing 5.4.6 clusters (RED-37233)
</strong>
Upgrade clusters to latest version.
</p>
</li>
<li>
<p>
<strong>
Node CPU usage is reported instead of pod CPU usage (RED-36884)
</strong>
In Kubernetes, the reported node CPU usage is the usage of the Kubernetes worker node hosting the REC pod.
</p>
</li>
<li>
<p>
<strong>
An unreachable cluster has status running (RED-32805)
</strong>
When a cluster is in an unreachable state, the state remains
<code>
running
</code>
instead of triggering an error.
</p>
</li>
<li>
<p>
<strong>
Long cluster names cause routes to be rejected (RED-25871)
</strong>
A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name exceeds 63 characters. The workaround is to limit the cluster name to 20 characters or fewer.
</p>
</li>
<li>
<p>
<strong>
Cluster CR (REC) errors are not reported after invalid updates (RED-25542)
</strong>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</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/kubernetes/release-notes/7-2-4-releases/7-2-4-12/"/>
<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/programmability/eval-intro/.html | <section class="prose w-full py-12">
<h1>
Scripting with Lua
</h1>
<p class="text-lg -mt-5 mb-10">
Executing Lua in Redis
</p>
<p>
Redis lets users upload and execute Lua scripts on the server.
Scripts can employ programmatic control structures and use most of the
<a href="/docs/latest/commands/">
commands
</a>
while executing to access the database.
Because scripts execute in the server, reading and writing data from scripts is very efficient.
</p>
<p>
Redis guarantees the script's atomic execution.
While executing the script, all server activities are blocked during its entire runtime.
These semantics mean that all of the script's effects either have yet to happen or had already happened.
</p>
<p>
Scripting offers several properties that can be valuable in many cases.
These include:
</p>
<ul>
<li>
Providing locality by executing logic where data lives. Data locality reduces overall latency and saves networking resources.
</li>
<li>
Blocking semantics that ensure the script's atomic execution.
</li>
<li>
Enabling the composition of simple capabilities that are either missing from Redis or are too niche to be a part of it.
</li>
</ul>
<p>
Lua lets you run part of your application logic inside Redis.
Such scripts can perform conditional updates across multiple keys, possibly combining several different data types atomically.
</p>
<p>
Scripts are executed in Redis by an embedded execution engine.
Presently, Redis supports a single scripting engine, the
<a href="https://www.lua.org/">
Lua 5.1
</a>
interpreter.
Please refer to the
<a href="/docs/latest/develop/interact/programmability/lua-api">
Redis Lua API Reference
</a>
page for complete documentation.
</p>
<p>
Although the server executes them, Eval scripts are regarded as a part of the client-side application, which is why they're not named, versioned, or persisted.
So all scripts may need to be reloaded by the application at any time if missing (after a server restart, fail-over to a replica, etc.).
As of version 7.0,
<a href="/docs/latest/develop/interact/programmability/functions-intro/">
Redis Functions
</a>
offer an alternative approach to programmability which allow the server itself to be extended with additional programmed logic.
</p>
<h2 id="getting-started">
Getting started
</h2>
<p>
We'll start scripting with Redis by using the
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
command.
</p>
<p>
Here's our first example:
</p>
<pre tabindex="0"><code>> EVAL "return 'Hello, scripting!'" 0
"Hello, scripting!"
</code></pre>
<p>
In this example,
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
takes two arguments.
The first argument is a string that consists of the script's Lua source code.
The script doesn't need to include any definitions of Lua function.
It is just a Lua program that will run in the Redis engine's context.
</p>
<p>
The second argument is the number of arguments that follow the script's body, starting from the third argument, representing Redis key names.
In this example, we used the value
<em>
0
</em>
because we didn't provide the script with any arguments, whether the names of keys or not.
</p>
<h2 id="script-parameterization">
Script parameterization
</h2>
<p>
It is possible, although highly ill-advised, to have the application dynamically generate script source code per its needs.
For example, the application could send these two entirely different, but at the same time perfectly identical scripts:
</p>
<pre tabindex="0"><code>redis> EVAL "return 'Hello'" 0
"Hello"
redis> EVAL "return 'Scripting!'" 0
"Scripting!"
</code></pre>
<p>
Although this mode of operation isn't blocked by Redis, it is an anti-pattern due to script cache considerations (more on the topic below).
Instead of having your application generate subtle variations of the same scripts, you can parametrize them and pass any arguments needed for to execute them.
</p>
<p>
The following example demonstrates how to achieve the same effects as above, but via parameterization:
</p>
<pre tabindex="0"><code>redis> EVAL "return ARGV[1]" 0 Hello
"Hello"
redis> EVAL "return ARGV[1]" 0 Parameterization!
"Parameterization!"
</code></pre>
<p>
At this point, it is essential to understand the distinction Redis makes between input arguments that are names of keys and those that aren't.
</p>
<p>
While key names in Redis are just strings, unlike any other string values, these represent keys in the database.
The name of a key is a fundamental concept in Redis and is the basis for operating the Redis Cluster.
</p>
<p>
<strong>
Important:
</strong>
to ensure the correct execution of scripts, both in standalone and clustered deployments, all names of keys that a script accesses must be explicitly provided as input key arguments.
The script
<strong>
should only
</strong>
access keys whose names are given as input arguments.
Scripts
<strong>
should never
</strong>
access keys with programmatically-generated names or based on the contents of data structures stored in the database.
</p>
<p>
Any input to the function that isn't the name of a key is a regular input argument.
</p>
<p>
In the example above, both
<em>
Hello
</em>
and
<em>
Parameterization!
</em>
regular input arguments for the script.
Because the script doesn't touch any keys, we use the numerical argument
<em>
0
</em>
to specify there are no key name arguments.
The execution context makes arguments available to the script through
<a href="/docs/latest/develop/interact/programmability/lua-api#the-keys-global-variable">
<em>
KEYS
</em>
</a>
and
<a href="/docs/latest/develop/interact/programmability/lua-api#the-argv-global-variable">
<em>
ARGV
</em>
</a>
global runtime variables.
The
<em>
KEYS
</em>
table is pre-populated with all key name arguments provided to the script before its execution, whereas the
<em>
ARGV
</em>
table serves a similar purpose but for regular arguments.
</p>
<p>
The following attempts to demonstrate the distribution of input arguments between the scripts
<em>
KEYS
</em>
and
<em>
ARGV
</em>
runtime global variables:
</p>
<pre tabindex="0"><code>redis> EVAL "return { KEYS[1], KEYS[2], ARGV[1], ARGV[2], ARGV[3] }" 2 key1 key2 arg1 arg2 arg3
1) "key1"
2) "key2"
3) "arg1"
4) "arg2"
5) "arg3"
</code></pre>
<p>
<strong>
Note:
</strong>
as can been seen above, Lua's table arrays are returned as
<a href="/docs/latest/develop/reference/protocol-spec/#resp-arrays">
RESP2 array replies
</a>
, so it is likely that your client's library will convert it to the native array data type in your programming language.
Please refer to the rules that govern
<a href="/docs/latest/develop/interact/programmability/lua-api#data-type-conversion">
data type conversion
</a>
for more pertinent information.
</p>
<h2 id="interacting-with-redis-from-a-script">
Interacting with Redis from a script
</h2>
<p>
It is possible to call Redis commands from a Lua script either via
<a href="/docs/latest/develop/interact/programmability/lua-api#redis.call">
<code>
redis.call()
</code>
</a>
or
<a href="/docs/latest/develop/interact/programmability/lua-api#redis.pcall">
<code>
redis.pcall()
</code>
</a>
.
</p>
<p>
The two are nearly identical.
Both execute a Redis command along with its provided arguments, if these represent a well-formed command.
However, the difference between the two functions lies in the manner in which runtime errors (such as syntax errors, for example) are handled.
Errors raised from calling
<code>
redis.call()
</code>
function are returned directly to the client that had executed it.
Conversely, errors encountered when calling the
<code>
redis.pcall()
</code>
function are returned to the script's execution context instead for possible handling.
</p>
<p>
For example, consider the following:
</p>
<pre tabindex="0"><code>> EVAL "return redis.call('SET', KEYS[1], ARGV[1])" 1 foo bar
OK
</code></pre>
<p>
The above script accepts one key name and one value as its input arguments.
When executed, the script calls the
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
command to set the input key,
<em>
foo
</em>
, with the string value "bar".
</p>
<h2 id="script-cache">
Script cache
</h2>
<p>
Until this point, we've used the
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
command to run our script.
</p>
<p>
Whenever we call
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
, we also include the script's source code with the request.
Repeatedly calling
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
to execute the same set of parameterized scripts, wastes both network bandwidth and also has some overheads in Redis.
Naturally, saving on network and compute resources is key, so, instead, Redis provides a caching mechanism for scripts.
</p>
<p>
Every script you execute with
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
is stored in a dedicated cache that the server keeps.
The cache's contents are organized by the scripts' SHA1 digest sums, so the SHA1 digest sum of a script uniquely identifies it in the cache.
You can verify this behavior by running
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
and calling
<a href="/docs/latest/commands/info/">
<code>
INFO
</code>
</a>
afterward.
You'll notice that the
<em>
used_memory_scripts_eval
</em>
and
<em>
number_of_cached_scripts
</em>
metrics grow with every new script that's executed.
</p>
<p>
As mentioned above, dynamically-generated scripts are an anti-pattern.
Generating scripts during the application's runtime may, and probably will, exhaust the host's memory resources for caching them.
Instead, scripts should be as generic as possible and provide customized execution via their arguments.
</p>
<p>
A script is loaded to the server's cache by calling the
<a href="/docs/latest/commands/script-load/">
<code>
SCRIPT LOAD
</code>
</a>
command and providing its source code.
The server doesn't execute the script, but instead just compiles and loads it to the server's cache.
Once loaded, you can execute the cached script with the SHA1 digest returned from the server.
</p>
<p>
Here's an example of loading and then executing a cached script:
</p>
<pre tabindex="0"><code>redis> SCRIPT LOAD "return 'Immabe a cached script'"
"c664a3bf70bd1d45c4284ffebb65a6f2299bfc9f"
redis> EVALSHA c664a3bf70bd1d45c4284ffebb65a6f2299bfc9f 0
"Immabe a cached script"
</code></pre>
<h3 id="cache-volatility">
Cache volatility
</h3>
<p>
The Redis script cache is
<strong>
always volatile
</strong>
.
It isn't considered as a part of the database and is
<strong>
not persisted
</strong>
.
The cache may be cleared when the server restarts, during fail-over when a replica assumes the master role, or explicitly by
<a href="/docs/latest/commands/script-flush/">
<code>
SCRIPT FLUSH
</code>
</a>
.
That means that cached scripts are ephemeral, and the cache's contents can be lost at any time.
</p>
<p>
Applications that use scripts should always call
<a href="/docs/latest/commands/evalsha/">
<code>
EVALSHA
</code>
</a>
to execute them.
The server returns an error if the script's SHA1 digest is not in the cache.
For example:
</p>
<pre tabindex="0"><code>redis> EVALSHA ffffffffffffffffffffffffffffffffffffffff 0
(error) NOSCRIPT No matching script
</code></pre>
<p>
In this case, the application should first load it with
<a href="/docs/latest/commands/script-load/">
<code>
SCRIPT LOAD
</code>
</a>
and then call
<a href="/docs/latest/commands/evalsha/">
<code>
EVALSHA
</code>
</a>
once more to run the cached script by its SHA1 sum.
Most of Redis' clients already provide utility APIs for doing that automatically.
Please consult your client's documentation regarding the specific details.
</p>
<h3 id="evalsha-in-the-context-of-pipelining">
<code>
EVALSHA
</code>
in the context of pipelining
</h3>
<p>
Special care should be given executing
<a href="/docs/latest/commands/evalsha/">
<code>
EVALSHA
</code>
</a>
in the context of a
<a href="/docs/latest/develop/use/pipelining/">
pipelined request
</a>
.
The commands in a pipelined request run in the order they are sent, but other clients' commands may be interleaved for execution between these.
Because of that, the
<code>
NOSCRIPT
</code>
error can return from a pipelined request but can't be handled.
</p>
<p>
Therefore, a client library's implementation should revert to using plain
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
of parameterized in the context of a pipeline.
</p>
<h3 id="script-cache-semantics">
Script cache semantics
</h3>
<p>
During normal operation, an application's scripts are meant to stay indefinitely in the cache (that is, until the server is restarted or the cache being flushed).
The underlying reasoning is that the script cache contents of a well-written application are unlikely to grow continuously.
Even large applications that use hundreds of cached scripts shouldn't be an issue in terms of cache memory usage.
</p>
<p>
The only way to flush the script cache is by explicitly calling the
<a href="/docs/latest/commands/script-flush/">
<code>
SCRIPT FLUSH
</code>
</a>
command.
Running the command will
<em>
completely flush
</em>
the scripts cache, removing all the scripts executed so far.
Typically, this is only needed when the instance is going to be instantiated for another customer or application in a cloud environment.
</p>
<p>
Also, as already mentioned, restarting a Redis instance flushes the non-persistent script cache.
However, from the point of view of the Redis client, there are only two ways to make sure that a Redis instance was not restarted between two different commands:
</p>
<ul>
<li>
The connection we have with the server is persistent and was never closed so far.
</li>
<li>
The client explicitly checks the
<code>
run_id
</code>
field in the
<a href="/docs/latest/commands/info/">
<code>
INFO
</code>
</a>
command to ensure the server was not restarted and is still the same process.
</li>
</ul>
<p>
Practically speaking, it is much simpler for the client to assume that in the context of a given connection, cached scripts are guaranteed to be there unless the administrator explicitly invoked the
<a href="/docs/latest/commands/script-flush/">
<code>
SCRIPT FLUSH
</code>
</a>
command.
The fact that the user can count on Redis to retain cached scripts is semantically helpful in the context of pipelining.
</p>
<h2 id="the-script-command">
The
<code>
SCRIPT
</code>
command
</h2>
<p>
The Redis
<a href="/docs/latest/commands/script/">
<code>
SCRIPT
</code>
</a>
provides several ways for controlling the scripting subsystem.
These are:
</p>
<ul>
<li>
<p>
<a href="/docs/latest/commands/script-flush/">
<code>
SCRIPT FLUSH
</code>
</a>
: this command is the only way to force Redis to flush the scripts cache.
It is most useful in environments where the same Redis instance is reassigned to different uses.
It is also helpful for testing client libraries' implementations of the scripting feature.
</p>
</li>
<li>
<p>
<a href="/docs/latest/commands/script-exists/">
<code>
SCRIPT EXISTS
</code>
</a>
: given one or more SHA1 digests as arguments, this command returns an array of
<em>
1
</em>
's and
<em>
0
</em>
's.
<em>
1
</em>
means the specific SHA1 is recognized as a script already present in the scripting cache.
<em>
0
</em>
's meaning is that a script with this SHA1 wasn't loaded before (or at least never since the latest call to
<a href="/docs/latest/commands/script-flush/">
<code>
SCRIPT FLUSH
</code>
</a>
).
</p>
</li>
<li>
<p>
<code>
SCRIPT LOAD script
</code>
: this command registers the specified script in the Redis script cache.
It is a useful command in all the contexts where we want to ensure that
<a href="/docs/latest/commands/evalsha/">
<code>
EVALSHA
</code>
</a>
doesn't not fail (for instance, in a pipeline or when called from a
<a href="/docs/latest/commands/multi/">
<code>
MULTI
</code>
</a>
/
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
<a href="/docs/latest/develop/interact/transactions/">
transaction
</a>
, without the need to execute the script.
</p>
</li>
<li>
<p>
<a href="/docs/latest/commands/script-kill/">
<code>
SCRIPT KILL
</code>
</a>
: this command is the only way to interrupt a long-running script (a.k.a slow script), short of shutting down the server.
A script is deemed as slow once its execution's duration exceeds the configured
<a href="/docs/latest/develop/interact/programmability/#maximum-execution-time">
maximum execution time
</a>
threshold.
The
<a href="/docs/latest/commands/script-kill/">
<code>
SCRIPT KILL
</code>
</a>
command can be used only with scripts that did not modify the dataset during their execution (since stopping a read-only script does not violate the scripting engine's guaranteed atomicity).
</p>
</li>
<li>
<p>
<a href="/docs/latest/commands/script-debug/">
<code>
SCRIPT DEBUG
</code>
</a>
: controls use of the built-in
<a href="/docs/latest/develop/interact/programmability/lua-debugging/">
Redis Lua scripts debugger
</a>
.
</p>
</li>
</ul>
<h2 id="script-replication">
Script replication
</h2>
<p>
In standalone deployments, a single Redis instance called
<em>
master
</em>
manages the entire database.
A
<a href="/docs/latest/operate/oss_and_stack/management/scaling/">
clustered deployment
</a>
has at least three masters managing the sharded database.
Redis uses
<a href="/docs/latest/operate/oss_and_stack/management/replication/">
replication
</a>
to maintain one or more replicas, or exact copies, for any given master.
</p>
<p>
Because scripts can modify the data, Redis ensures all write operations performed by a script are also sent to replicas to maintain consistency.
There are two conceptual approaches when it comes to script replication:
</p>
<ol>
<li>
Verbatim replication: the master sends the script's source code to the replicas.
Replicas then execute the script and apply the write effects.
This mode can save on replication bandwidth in cases where short scripts generate many commands (for example, a
<em>
for
</em>
loop).
However, this replication mode means that replicas redo the same work done by the master, which is wasteful.
More importantly, it also requires
<a href="#scripts-with-deterministic-writes">
all write scripts to be deterministic
</a>
.
</li>
<li>
Effects replication: only the script's data-modifying commands are replicated.
Replicas then run the commands without executing any scripts.
While potentially lengthier in terms of network traffic, this replication mode is deterministic by definition and therefore doesn't require special consideration.
</li>
</ol>
<p>
Verbatim script replication was the only mode supported until Redis 3.2, in which effects replication was added.
The
<em>
lua-replicate-commands
</em>
configuration directive and
<a href="/docs/latest/develop/interact/programmability/lua-api#redis.replicate_commands">
<code>
redis.replicate_commands()
</code>
</a>
Lua API can be used to enable it.
</p>
<p>
In Redis 5.0, effects replication became the default mode.
As of Redis 7.0, verbatim replication is no longer supported.
</p>
<h3 id="replicating-commands-instead-of-scripts">
Replicating commands instead of scripts
</h3>
<p>
Starting with Redis 3.2, it is possible to select an alternative replication method.
Instead of replicating whole scripts, we can replicate the write commands generated by the script.
We call this
<strong>
script effects replication
</strong>
.
</p>
<p>
<strong>
Note:
</strong>
starting with Redis 5.0, script effects replication is the default mode and does not need to be explicitly enabled.
</p>
<p>
In this replication mode, while Lua scripts are executed, Redis collects all the commands executed by the Lua scripting engine that actually modify the dataset.
When the script execution finishes, the sequence of commands that the script generated are wrapped into a
<a href="/docs/latest/commands/multi/">
<code>
MULTI
</code>
</a>
/
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
<a href="/docs/latest/develop/interact/transactions/">
transaction
</a>
and are sent to the replicas and AOF.
</p>
<p>
This is useful in several ways depending on the use case:
</p>
<ul>
<li>
When the script is slow to compute, but the effects can be summarized by a few write commands, it is a shame to re-compute the script on the replicas or when reloading the AOF.
In this case, it is much better to replicate just the effects of the script.
</li>
<li>
When script effects replication is enabled, the restrictions on non-deterministic functions are removed.
You can, for example, use the
<a href="/docs/latest/commands/time/">
<code>
TIME
</code>
</a>
or
<a href="/docs/latest/commands/srandmember/">
<code>
SRANDMEMBER
</code>
</a>
commands inside your scripts freely at any place.
</li>
<li>
The Lua PRNG in this mode is seeded randomly on every call.
</li>
</ul>
<p>
Unless already enabled by the server's configuration or defaults (before Redis 7.0), you need to issue the following Lua command before the script performs a write:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-lua" data-lang="lua"><span class="line"><span class="cl"><span class="n">redis.replicate_commands</span><span class="p">()</span>
</span></span></code></pre>
</div>
<p>
The
<a href="/docs/latest/develop/interact/programmability/lua-api#redis.replicate_commands">
<code>
redis.replicate_commands()
</code>
</a>
function returns _true) if script effects replication was enabled;
otherwise, if the function was called after the script already called a write command,
it returns
<em>
false
</em>
, and normal whole script replication is used.
</p>
<p>
This function is deprecated as of Redis 7.0, and while you can still call it, it will always succeed.
</p>
<h3 id="scripts-with-deterministic-writes">
Scripts with deterministic writes
</h3>
<p>
<strong>
Note:
</strong>
Starting with Redis 5.0, script replication is by default effect-based rather than verbatim.
In Redis 7.0, verbatim script replication had been removed entirely.
The following section only applies to versions lower than Redis 7.0 when not using effect-based script replication.
</p>
<p>
An important part of scripting is writing scripts that only change the database in a deterministic way.
Scripts executed in a Redis instance are, by default until version 5.0, propagated to replicas and to the AOF file by sending the script itself -- not the resulting commands.
Since the script will be re-run on the remote host (or when reloading the AOF file), its changes to the database must be reproducible.
</p>
<p>
The reason for sending the script is that it is often much faster than sending the multiple commands that the script generates.
If the client is sending many scripts to the master, converting the scripts into individual commands for the replica / AOF would result in too much bandwidth for the replication link or the Append Only File (and also too much CPU since dispatching a command received via the network is a lot more work for Redis compared to dispatching a command invoked by Lua scripts).
</p>
<p>
Normally replicating scripts instead of the effects of the scripts makes sense, however not in all the cases.
So starting with Redis 3.2, the scripting engine is able to, alternatively, replicate the sequence of write commands resulting from the script execution, instead of replication the script itself.
</p>
<p>
In this section, we'll assume that scripts are replicated verbatim by sending the whole script.
Let's call this replication mode
<strong>
verbatim scripts replication
</strong>
.
</p>
<p>
The main drawback with the
<em>
whole scripts replication
</em>
approach is that scripts are required to have the following property:
the script
<strong>
always must
</strong>
execute the same Redis
<em>
write
</em>
commands with the same arguments given the same input data set.
Operations performed by the script can't depend on any hidden (non-explicit) information or state that may change as the script execution proceeds or between different executions of the script.
Nor can it depend on any external input from I/O devices.
</p>
<p>
Acts such as using the system time, calling Redis commands that return random values (e.g.,
<a href="/docs/latest/commands/randomkey/">
<code>
RANDOMKEY
</code>
</a>
), or using Lua's random number generator, could result in scripts that will not evaluate consistently.
</p>
<p>
To enforce the deterministic behavior of scripts, Redis does the following:
</p>
<ul>
<li>
Lua does not export commands to access the system time or other external states.
</li>
<li>
Redis will block the script with an error if a script calls a Redis command able to alter the data set
<strong>
after
</strong>
a Redis
<em>
random
</em>
command like
<a href="/docs/latest/commands/randomkey/">
<code>
RANDOMKEY
</code>
</a>
,
<a href="/docs/latest/commands/srandmember/">
<code>
SRANDMEMBER
</code>
</a>
,
<a href="/docs/latest/commands/time/">
<code>
TIME
</code>
</a>
.
That means that read-only scripts that don't modify the dataset can call those commands.
Note that a
<em>
random command
</em>
does not necessarily mean a command that uses random numbers: any non-deterministic command is considered as a random command (the best example in this regard is the
<a href="/docs/latest/commands/time/">
<code>
TIME
</code>
</a>
command).
</li>
<li>
In Redis version 4.0, commands that may return elements in random order, such as
<a href="/docs/latest/commands/smembers/">
<code>
SMEMBERS
</code>
</a>
(because Redis Sets are
<em>
unordered
</em>
), exhibit a different behavior when called from Lua,
and undergo a silent lexicographical sorting filter before returning data to Lua scripts.
So
<code>
redis.call("SMEMBERS",KEYS[1])
</code>
will always return the Set elements in the same order, while the same command invoked by normal clients may return different results even if the key contains exactly the same elements.
However, starting with Redis 5.0, this ordering is no longer performed because replicating effects circumvents this type of non-determinism.
In general, even when developing for Redis 4.0, never assume that certain commands in Lua will be ordered, but instead rely on the documentation of the original command you call to see the properties it provides.
</li>
<li>
Lua's pseudo-random number generation function
<code>
math.random
</code>
is modified and always uses the same seed for every execution.
This means that calling
<a href="/docs/latest/develop/interact/programmability/lua-api#runtime-libraries">
<code>
math.random
</code>
</a>
will always generate the same sequence of numbers every time a script is executed (unless
<code>
math.randomseed
</code>
is used).
</li>
</ul>
<p>
All that said, you can still use commands that write and random behavior with a simple trick.
Imagine that you want to write a Redis script that will populate a list with N random integers.
</p>
<p>
The initial implementation in Ruby could look like this:
</p>
<pre tabindex="0"><code>require 'rubygems'
require 'redis'
r = Redis.new
RandomPushScript = <<EOF
local i = tonumber(ARGV[1])
local res
while (i > 0) do
res = redis.call('LPUSH',KEYS[1],math.random())
i = i-1
end
return res
EOF
r.del(:mylist)
puts r.eval(RandomPushScript,[:mylist],[10,rand(2**32)])
</code></pre>
<p>
Every time this code runs, the resulting list will have exactly the
following elements:
</p>
<pre tabindex="0"><code>redis> LRANGE mylist 0 -1
1) "0.74509509873814"
2) "0.87390407681181"
3) "0.36876626981831"
4) "0.6921941534114"
5) "0.7857992587545"
6) "0.57730350670279"
7) "0.87046522734243"
8) "0.09637165539729"
9) "0.74990198051087"
10) "0.17082803611217"
</code></pre>
<p>
To make the script both deterministic and still have it produce different random elements,
we can add an extra argument to the script that's the seed to Lua's pseudo-random number generator.
The new script is as follows:
</p>
<pre tabindex="0"><code>RandomPushScript = <<EOF
local i = tonumber(ARGV[1])
local res
math.randomseed(tonumber(ARGV[2]))
while (i > 0) do
res = redis.call('LPUSH',KEYS[1],math.random())
i = i-1
end
return res
EOF
r.del(:mylist)
puts r.eval(RandomPushScript,1,:mylist,10,rand(2**32))
</code></pre>
<p>
What we are doing here is sending the seed of the PRNG as one of the arguments.
The script output will always be the same given the same arguments (our requirement) but we are changing one of the arguments at every invocation,
generating the random seed client-side.
The seed will be propagated as one of the arguments both in the replication link and in the Append Only File,
guaranteeing that the same changes will be generated when the AOF is reloaded or when the replica processes the script.
</p>
<p>
Note: an important part of this behavior is that the PRNG that Redis implements as
<code>
math.random
</code>
and
<code>
math.randomseed
</code>
is guaranteed to have the same output regardless of the architecture of the system running Redis.
32-bit, 64-bit, big-endian and little-endian systems will all produce the same output.
</p>
<h2 id="debugging-eval-scripts">
Debugging Eval scripts
</h2>
<p>
Starting with Redis 3.2, Redis has support for native Lua debugging.
The Redis Lua debugger is a remote debugger consisting of a server, which is Redis itself, and a client, which is by default
<a href="/docs/latest/develop/tools/cli/">
<code>
redis-cli
</code>
</a>
.
</p>
<p>
The Lua debugger is described in the
<a href="/docs/latest/develop/interact/programmability/lua-debugging/">
Lua scripts debugging
</a>
section of the Redis documentation.
</p>
<h2 id="execution-under-low-memory-conditions">
Execution under low memory conditions
</h2>
<p>
When memory usage in Redis exceeds the
<code>
maxmemory
</code>
limit, the first write command encountered in the script that uses additional memory will cause the script to abort (unless
<a href="/docs/latest/develop/interact/programmability/lua-api#redis.pcall">
<code>
redis.pcall
</code>
</a>
was used).
</p>
<p>
However, an exception to the above is when the script's first write command does not use additional memory, as is the case with (for example,
<a href="/docs/latest/commands/del/">
<code>
DEL
</code>
</a>
and
<a href="/docs/latest/commands/lrem/">
<code>
LREM
</code>
</a>
).
In this case, Redis will allow all commands in the script to run to ensure atomicity.
If subsequent writes in the script consume additional memory, Redis' memory usage can exceed the threshold set by the
<code>
maxmemory
</code>
configuration directive.
</p>
<p>
Another scenario in which a script can cause memory usage to cross the
<code>
maxmemory
</code>
threshold is when the execution begins when Redis is slightly below
<code>
maxmemory
</code>
, so the script's first write command is allowed.
As the script executes, subsequent write commands consume more memory leading to the server using more RAM than the configured
<code>
maxmemory
</code>
directive.
</p>
<p>
In those scenarios, you should consider setting the
<code>
maxmemory-policy
</code>
configuration directive to any values other than
<code>
noeviction
</code>
.
In addition, Lua scripts should be as fast as possible so that eviction can kick in between executions.
</p>
<p>
Note that you can change this behaviour by using
<a href="#eval-flags">
flags
</a>
</p>
<h2 id="eval-flags">
Eval flags
</h2>
<p>
Normally, when you run an Eval script, the server does not know how it accesses the database.
By default, Redis assumes that all scripts read and write data.
However, starting with Redis 7.0, there's a way to declare flags when creating a script in order to tell Redis how it should behave.
</p>
<p>
The way to do that is by using a Shebang statement on the first line of the script like so:
</p>
<pre tabindex="0"><code>#!lua flags=no-writes,allow-stale
local x = redis.call('get','x')
return x
</code></pre>
<p>
Note that as soon as Redis sees the
<code>
#!
</code>
comment, it'll treat the script as if it declares flags, even if no flags are defined,
it still has a different set of defaults compared to a script without a
<code>
#!
</code>
line.
</p>
<p>
Another difference is that scripts without
<code>
#!
</code>
can run commands that access keys belonging to different cluster hash slots, but ones with
<code>
#!
</code>
inherit the default flags, so they cannot.
</p>
<p>
Please refer to
<a href="/docs/latest/develop/interact/programmability/lua-api#script_flags">
Script flags
</a>
to learn about the various scripts and the defaults.
</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/programmability/eval-intro/"/>
<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.20.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v2.20.0, February 2023
</h1>
<p class="text-lg -mt-5 mb-10">
RedisInsight v2.20.0
</p>
<h2 id="2200-february-2023">
2.20.0 (February 2023)
</h2>
<p>
This is the General Availability (GA) release of RedisInsight 2.20.
</p>
<h3 id="highlights">
Highlights
</h3>
<ul>
<li>
Visualizations of
<a href="https://redis.io/docs/stack/search/">
search
</a>
and
<a href="https://redis.io/docs/stack/graph/">
graph
</a>
execution plans in Workbench
</li>
<li>
Guided walkthrough of RedisInsight tools and capabilities for new users
</li>
<li>
Bulk export database connections to a file
</li>
<li>
Upload values of
<a href="https://redis.io/docs/stack/json/">
RedisJSON
</a>
from a file for new keys in Browser
</li>
<li>
Visualizations of
<a href="https://redis.io/commands/client-list/">
CLIENT LIST
</a>
in Workbench
</li>
<li>
See filters previously used in Browser
</li>
</ul>
<h3 id="details">
Details
</h3>
<p>
<strong>
Features and improvements
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1629">
#1629
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1739">
#1739
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1740">
#1740
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1781">
#1781
</a>
Investigate and optimize your
<a href="https://redis.io/docs/stack/search/">
search
</a>
and
<a href="https://redis.io/docs/stack/graph/">
graph
</a>
queries with new visualizations of execution plans in Workbench. Visualizations are supported for
<a href="https://redis.io/commands/ft.explain/">
FT.EXPLAIN
</a>
,
<a href="https://redis.io/commands/ft.profile/">
FT.PROFILE
</a>
,
<a href="https://redis.io/commands/graph.explain/">
GRAPH.EXPLAIN
</a>
, and
<a href="https://redis.io/commands/graph.profile/">
GRAPH.PROFILE
</a>
.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1698">
#1698
</a>
Explore RedisInsight's tools and capabilities with a new walkthrough when you start RedisInsight for the first time.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1631">
#1631
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1632">
#1632
</a>
Migrate your database connections to another RedisInsight instance by performing a bulk export of database connections to a file.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1741">
#1741
</a>
Upload
<a href="https://redis.io/docs/stack/json/">
RedisJSON
</a>
values from a file for new keys in Browser.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1653">
#1653
</a>
Analyze client connections using new Workbench visualizations for
<a href="https://redis.io/commands/client-list/">
CLIENT LIST
</a>
.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1625">
#1625
</a>
Quickly set filters previously used in Browser by selecting them from the list of recently used filters.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1713">
#1713
</a>
See your new Redis keys added in Browser without a need to refresh the list of keys.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1681">
#1681
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1692">
#1692
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1693">
#1693
</a>
Avoid the timeout connection errors by configuring the connection timeout for databases added manually via host and port.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1696">
#1696
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/1703">
#1703
</a>
Test the database connection before adding the database.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1689">
#1689
</a>
Update the port of an existing database connection instead of adding a new one.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1731">
#1731
</a>
Use database indexes based on
<a href="https://redis.io/commands/info/">
INFO keyspace
</a>
.
</li>
</ul>
<p>
<strong>
Bugs
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1678">
#1678
</a>
Prevent crashes when SSH is set up on Linux.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/1697">
#1697
</a>
Prevent crashes when working with
<a href="https://redis.io/docs/data-types/streams">
Redis streams
</a>
with large IDs.
</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.20.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/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/readers/streamreader/.html | <section class="prose w-full py-12 max-w-none">
<h1>
StreamReader
</h1>
<p class="text-lg -mt-5 mb-10">
Reads Redis stream data.
</p>
<p>
Reads Redis stream data.
</p>
<h2 id="parameters">
Parameters
</h2>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Default value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
batchSize
</td>
<td>
integer
</td>
<td>
1
</td>
<td>
The number of new messages that will cause the functions to run
</td>
</tr>
<tr>
<td>
duration
</td>
<td>
integer
</td>
<td>
0
</td>
<td>
How many seconds to wait before execution, regardless of batch size
</td>
</tr>
<tr>
<td>
failurePolicy
</td>
<td>
FailurePolicy
</td>
<td>
FailurePolicy.CONTINUE
</td>
<td>
How to handle execution failure (CONTINUE/ABORT/RETRY)
</td>
</tr>
<tr>
<td>
failureRetryInterval
</td>
<td>
integer
</td>
<td>
5000
</td>
<td>
The number of seconds to wait before retrying
</td>
</tr>
<tr>
<td>
pattern
</td>
<td>
string
</td>
<td>
"*" (match all keys)
</td>
<td>
The pattern of keys that store streams
</td>
</tr>
<tr>
<td>
startId
</td>
<td>
string
</td>
<td>
"0-0"
</td>
<td>
Start reading from this stream ID
</td>
</tr>
<tr>
<td>
trimStream
</td>
<td>
boolean
</td>
<td>
true
</td>
<td>
Whether or not to trim the stream
</td>
</tr>
</tbody>
</table>
<h2 id="output-records">
Output records
</h2>
<p>
Creates a record for each message in the input stream.
</p>
<p>
Each record is a
<code>
HashMap<String, Object>
</code>
with the following fields:
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
id
</td>
<td>
string
</td>
<td>
The message's ID
</td>
</tr>
<tr>
<td>
key
</td>
<td>
string
</td>
<td>
The stream key name
</td>
</tr>
<tr>
<td>
value
</td>
<td>
HashMap<String, byte[]>
</td>
<td>
The message's data
</td>
</tr>
</tbody>
</table>
<h2 id="examples">
Examples
</h2>
<p>
The following example creates a
<code>
StreamReader
</code>
with default values:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">StreamReader</span> <span class="n">reader</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamReader</span><span class="o">();</span>
</span></span></code></pre>
</div>
<p>
To change the parameter values for a
<code>
StreamReader
</code>
, use their setter methods:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">StreamReader</span> <span class="n">reader</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamReader</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="c1">// Get streams for keys that match "weather"
</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">setPattern</span><span class="o">(</span><span class="s">"weather"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// Run RedisGears functions after every 10 messages
</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">setBatchSize</span><span class="o">(</span><span class="mi">10</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/readers/streamreader/"/>
<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/callnext/.html | <section class="prose w-full py-12 max-w-none">
<h1>
CallNext
</h1>
<p class="text-lg -mt-5 mb-10">
Calls the next execution that overrides the command or the original command itself. A more flexible version of callNextArray.
</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="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">Object</span> <span class="nf">callNext</span><span class="o">(</span><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">args</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>
callNext
</code>
to run the next execution that overrides the command or the original command itself.
</p>
<p>
It is a more flexible version of
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/callnextarray/">
<code>
callNextArray
</code>
</a>
since the list of string arguments does not have to be an explicit
<code>
String[]
</code>
object. This allows function calls like:
<nobr>
<code>
callNext("key", "value")
</code>
.
</nobr>
</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>
string
</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="examples">
Examples
</h2>
<p>
Without
<code>
String[]
</code>
:
</p>
<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">callNext</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>
<p>
With
<code>
String[]
</code>
:
</p>
<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">callNext</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/callnext/"/>
<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/tdigest.trimmed_mean.html | <section class="prose w-full py-12">
<h1 class="command-name">
TDIGEST.TRIMMED_MEAN
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TDIGEST.TRIMMED_MEAN key low_cut_quantile high_cut_quantile</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.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) where N is the number of centroids
</dd>
</dl>
<p>
Returns an estimation of the mean value from the sketch, excluding observation values outside the low and high cutoff quantiles.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
is key name for an existing t-digest sketch.
</details>
<details open="">
<summary>
<code>
low_cut_quantile
</code>
</summary>
<p>
Foating-point value in the range [0..1], should be lower than
<code>
high_cut_quantile
</code>
</p>
<p>
When equal to 0: No low cut.
</p>
<p>
When higher than 0: Exclude observation values lower than this quantile.
</p>
</details>
<details open="">
<summary>
<code>
high_cut_quantile
</code>
</summary>
<p>
Floating-point value in the range [0..1], should be higher than
<code>
low_cut_quantile
</code>
</p>
<p>
When lower than 1: Exclude observation values higher than or equal to this quantile.
</p>
<p>
When equal to 1: No high cut.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
estimation of the mean value. 'nan' if the sketch is empty.
</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> TDIGEST.CREATE t COMPRESSION <span class="m">1000</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.ADD t <span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span> <span class="m">6</span> <span class="m">7</span> <span class="m">8</span> <span class="m">9</span> <span class="m">10</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.TRIMMED_MEAN t 0.1 0.6
</span></span><span class="line"><span class="cl"><span class="s2">"4"</span>
</span></span><span class="line"><span class="cl">redis> TDIGEST.TRIMMED_MEAN t 0.3 0.9
</span></span><span class="line"><span class="cl"><span class="s2">"6.5"</span>
</span></span><span class="line"><span class="cl">redis> TDIGEST.TRIMMED_MEAN t <span class="m">0</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl"><span class="s2">"5.5"</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/tdigest.trimmed_mean/"/>
<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/lrem/.html | <section class="prose w-full py-12">
<h1 class="command-name">
LREM
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">LREM key count element</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(N+M) where N is the length of the list and M is the number of elements removed.
</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>
Removes the first
<code>
count
</code>
occurrences of elements equal to
<code>
element
</code>
from the list
stored at
<code>
key
</code>
.
The
<code>
count
</code>
argument influences the operation in the following ways:
</p>
<ul>
<li>
<code>
count > 0
</code>
: Remove elements equal to
<code>
element
</code>
moving from head to tail.
</li>
<li>
<code>
count < 0
</code>
: Remove elements equal to
<code>
element
</code>
moving from tail to head.
</li>
<li>
<code>
count = 0
</code>
: Remove all elements equal to
<code>
element
</code>
.
</li>
</ul>
<p>
For example,
<code>
LREM list -2 "hello"
</code>
will remove the last two occurrences of
<code>
"hello"
</code>
in the list stored at
<code>
list
</code>
.
</p>
<p>
Note that non-existing keys are treated like empty lists, so when
<code>
key
</code>
does not
exist, the command will always return
<code>
0
</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> RPUSH mylist "hello"
(integer) 1
redis> RPUSH mylist "hello"
(integer) 2
redis> RPUSH mylist "foo"
(integer) 3
redis> RPUSH mylist "hello"
(integer) 4
redis> LREM mylist -2 "hello"
(integer) 2
redis> LRANGE mylist 0 -1
1) "hello"
2) "foo"
</pre>
<div class="prompt" style="">
<span>
redis>
</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#integers">
Integer reply
</a>
: the number of removed elements.
<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/lrem/"/>
<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/bitfields/.html | <section class="prose w-full py-12">
<h1>
Redis bitfields
</h1>
<p class="text-lg -mt-5 mb-10">
Introduction to Redis bitfields
</p>
<p>
Redis bitfields let you set, increment, and get integer values of arbitrary bit length.
For example, you can operate on anything from unsigned 1-bit integers to signed 63-bit integers.
</p>
<p>
These values are stored using binary-encoded Redis strings.
Bitfields support atomic read, write and increment operations, making them a good choice for managing counters and similar numerical values.
</p>
<h2 id="basic-commands">
Basic commands
</h2>
<ul>
<li>
<a href="/docs/latest/commands/bitfield/">
<code>
BITFIELD
</code>
</a>
atomically sets, increments and reads one or more values.
</li>
<li>
<a href="/docs/latest/commands/bitfield_ro/">
<code>
BITFIELD_RO
</code>
</a>
is a read-only variant of
<a href="/docs/latest/commands/bitfield/">
<code>
BITFIELD
</code>
</a>
.
</li>
</ul>
<h2 id="example">
Example
</h2>
<p>
Suppose you want to maintain two metrics for various bicycles: the current price and the number of owners over time. You can represent these counters with a 32-bit wide bitfield for each bike.
</p>
<ul>
<li>
Bike 1 initially costs 1,000 (counter in offset 0) and has never had an owner. After being sold, it's now considered used and the price instantly drops to reflect its new condition, and it now has an owner (offset 1). After quite some time, the bike becomes a classic. The original owner sells it for a profit, so the price goes up and the number of owners does as well.Finally, you can look at the bike's current price and number of owners.
</li>
</ul>
<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="bitfield_tutorial-stepbf">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_bitfield_tutorial-stepbf" name="bitfield_tutorial-stepbf" 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_bitfield_tutorial-stepbf" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-bitfield_tutorial-stepbf" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_bitfield_tutorial-stepbf" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> BITFIELD bike:1:stats SET u32 #0 1000
</span></span><span class="line hl"><span class="cl">1) (integer) 0
</span></span><span class="line hl"><span class="cl">> BITFIELD bike:1:stats INCRBY u32 #0 -50 INCRBY u32 #1 1
</span></span><span class="line hl"><span class="cl">1) (integer) 950
</span></span><span class="line hl"><span class="cl">2) (integer) 1
</span></span><span class="line hl"><span class="cl">> BITFIELD bike:1:stats INCRBY u32 #0 500 INCRBY u32 #1 1
</span></span><span class="line hl"><span class="cl">1) (integer) 1450
</span></span><span class="line hl"><span class="cl">2) (integer) 2
</span></span><span class="line hl"><span class="cl">> BITFIELD bike:1:stats GET u32 #0 GET u32 #1
</span></span><span class="line hl"><span class="cl">1) (integer) 1450
</span></span><span class="line hl"><span class="cl">2) (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_bitfield_tutorial-stepbf')" 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_bitfield_tutorial-stepbf" name="bitfield_tutorial-stepbf" 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_bitfield_tutorial-stepbf" title="Open example">
Python
</label>
<div aria-labelledby="tab-bitfield_tutorial-stepbf" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_bitfield_tutorial-stepbf" 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 Bitfield doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/bitfields/
</span></span></span><span class="line"><span class="cl"><span class="s2">"""</span>
</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></span><span class="line hl"><span class="cl"><span class="n">bf</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">bitfield</span><span class="p">(</span><span class="s2">"bike:1:stats"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">bf</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#0"</span><span class="p">,</span> <span class="mi">1000</span><span class="p">)</span><span class="o">.</span><span class="n">execute</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"># >>> [0]</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">bf</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#0"</span><span class="p">,</span> <span class="o">-</span><span class="mi">50</span><span class="p">)</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#1"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">execute</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"># >>> [950, 1]</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">bf</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#0"</span><span class="p">,</span> <span class="mi">500</span><span class="p">)</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#1"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">execute</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"># >>> [1450, 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">bf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#0"</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"u32"</span><span class="p">,</span> <span class="s2">"#1"</span><span class="p">)</span><span class="o">.</span><span class="n">execute</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"># >>> [1450, 2]</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_bitfield_tutorial-stepbf')" 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_bitfield_tutorial-stepbf" 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_bitfield.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_bitfield_tutorial-stepbf" name="bitfield_tutorial-stepbf" 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_bitfield_tutorial-stepbf" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-bitfield_tutorial-stepbf" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_bitfield_tutorial-stepbf" 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="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></span><span class="line hl"><span class="cl"><span class="kd">let</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">bitField</span><span class="p">(</span><span class="s2">"bike:1:stats"</span><span class="p">,</span> <span class="p">[{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">operation</span><span class="o">:</span> <span class="s1">'SET'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</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="nx">value</span><span class="o">:</span> <span class="mi">1000</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">res1</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="kd">let</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">bitField</span><span class="p">(</span><span class="s1">'bike:1:stats'</span><span class="p">,</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">operation</span><span class="o">:</span> <span class="s1">'INCRBY'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</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="nx">increment</span><span class="o">:</span> <span class="o">-</span><span class="mi">50</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="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">operation</span><span class="o">:</span> <span class="s1">'INCRBY'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</span><span class="o">:</span> <span class="s1">'#1'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">increment</span><span class="o">:</span> <span class="mi">1</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="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">// >>> [950, 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="kd">let</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">bitField</span><span class="p">(</span><span class="s1">'bike:1:stats'</span><span class="p">,</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">operation</span><span class="o">:</span> <span class="s1">'INCRBY'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</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="nx">increment</span><span class="o">:</span> <span class="mi">500</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="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">operation</span><span class="o">:</span> <span class="s1">'INCRBY'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</span><span class="o">:</span> <span class="s1">'#1'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">increment</span><span class="o">:</span> <span class="mi">1</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="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">// >>> [1450, 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="kd">let</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">bitField</span><span class="p">(</span><span class="s1">'bike:1:stats'</span><span class="p">,</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">operation</span><span class="o">:</span> <span class="s1">'GET'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</span><span class="o">:</span> <span class="s1">'#0'</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="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">operation</span><span class="o">:</span> <span class="s1">'GET'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">encoding</span><span class="o">:</span> <span class="s1">'u32'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">offset</span><span class="o">:</span> <span class="s1">'#1'</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="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">// >>> [1450, 2]
</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_bitfield_tutorial-stepbf')" 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_bitfield_tutorial-stepbf" 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-bitfield.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_bitfield_tutorial-stepbf" name="bitfield_tutorial-stepbf" 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_bitfield_tutorial-stepbf" title="Open example">
Java
</label>
<div aria-labelledby="tab-bitfield_tutorial-stepbf" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_bitfield_tutorial-stepbf" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><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></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">BitfieldExample</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="n">List</span><span class="o"><</span><span class="n">Long</span><span class="o">></span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bitfield</span><span class="o">(</span><span class="s">"bike:1:stats"</span><span class="o">,</span> <span class="s">"SET"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#0"</span><span class="o">,</span> <span class="s">"1000"</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">// >>> [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">List</span><span class="o"><</span><span class="n">Long</span><span class="o">></span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bitfield</span><span class="o">(</span><span class="s">"bike:1:stats"</span><span class="o">,</span> <span class="s">"INCRBY"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#0"</span><span class="o">,</span> <span class="s">"-50"</span><span class="o">,</span> <span class="s">"INCRBY"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#1"</span><span class="o">,</span> <span class="s">"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">// >>> [950, 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"><</span><span class="n">Long</span><span class="o">></span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bitfield</span><span class="o">(</span><span class="s">"bike:1:stats"</span><span class="o">,</span> <span class="s">"INCRBY"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#0"</span><span class="o">,</span> <span class="s">"500"</span><span class="o">,</span> <span class="s">"INCRBY"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#1"</span><span class="o">,</span> <span class="s">"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">res3</span><span class="o">);</span> <span class="c1">// >>> [1450, 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"><</span><span class="n">Long</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bitfield</span><span class="o">(</span><span class="s">"bike:1:stats"</span><span class="o">,</span> <span class="s">"GET"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#0"</span><span class="o">,</span> <span class="s">"GET"</span><span class="o">,</span> <span class="s">"u32"</span><span class="o">,</span> <span class="s">"#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">res4</span><span class="o">);</span> <span class="c1">// >>> [1450, 2]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bf' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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_bitfield_tutorial-stepbf')" 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_bitfield_tutorial-stepbf" 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/BitfieldExample.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_bitfield_tutorial-stepbf" name="bitfield_tutorial-stepbf" 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_bitfield_tutorial-stepbf" title="Open example">
Go
</label>
<div aria-labelledby="tab-bitfield_tutorial-stepbf" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_bitfield_tutorial-stepbf" 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_bf</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span 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">BitField</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1:stats"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"set"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#0"</span><span class="p">,</span> <span class="s">"1000"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [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">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">BitField</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"bike:1:stats"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"incrby"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#0"</span><span class="p">,</span> <span class="s">"-50"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"incrby"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#1"</span><span class="p">,</span> <span class="s">"1"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [950 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">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">BitField</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"bike:1:stats"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"incrby"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#0"</span><span class="p">,</span> <span class="s">"500"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"incrby"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#1"</span><span class="p">,</span> <span class="s">"1"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [1450 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">BitField</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1:stats"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"get"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#0"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"get"</span><span class="p">,</span> <span class="s">"u32"</span><span class="p">,</span> <span class="s">"#1"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [1450 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></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_bitfield_tutorial-stepbf')" 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_bitfield_tutorial-stepbf" 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/bitfield_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>
</div>
<h2 id="performance">
Performance
</h2>
<p>
<a href="/docs/latest/commands/bitfield/">
<code>
BITFIELD
</code>
</a>
is O(n), where
<em>
n
</em>
is the number of counters accessed.
</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/data-types/bitfields/"/>
<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/bootstrap/paths/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Paths object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the paths 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>
bigstore_path
</td>
<td>
string
</td>
<td>
Bigredis storage path
</td>
</tr>
<tr>
<td>
ccs_persistent_path
</td>
<td>
string
</td>
<td>
Persistent storage path of CCS
</td>
</tr>
<tr>
<td>
ephemeral_path
</td>
<td>
string
</td>
<td>
Ephemeral storage path
</td>
</tr>
<tr>
<td>
persistent_path
</td>
<td>
string
</td>
<td>
Persistent storage path
</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/bootstrap/paths/"/>
<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/xautoclaim/.html | <section class="prose w-full py-12">
<h1 class="command-name">
XAUTOCLAIM
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">XAUTOCLAIM key group consumer min-idle-time start [COUNT count]
[JUSTID]</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) if COUNT is small.
</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>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
This command transfers ownership of pending stream entries that match the specified criteria. Conceptually,
<code>
XAUTOCLAIM
</code>
is equivalent to calling
<a href="/docs/latest/commands/xpending/">
<code>
XPENDING
</code>
</a>
and then
<a href="/docs/latest/commands/xclaim/">
<code>
XCLAIM
</code>
</a>
,
but provides a more straightforward way to deal with message delivery failures via
<a href="/docs/latest/commands/scan/">
<code>
SCAN
</code>
</a>
-like semantics.
</p>
<p>
Like
<a href="/docs/latest/commands/xclaim/">
<code>
XCLAIM
</code>
</a>
, the command operates on the stream entries at
<code>
<key>
</code>
and in the context of the provided
<code>
<group>
</code>
.
It transfers ownership to
<code>
<consumer>
</code>
of messages pending for more than
<code>
<min-idle-time>
</code>
milliseconds and having an equal or greater ID than
<code>
<start>
</code>
.
</p>
<p>
The optional
<code>
<count>
</code>
argument, which defaults to 100, is the upper limit of the number of entries that the command attempts to claim.
Internally, the command begins scanning the consumer group's Pending Entries List (PEL) from
<code>
<start>
</code>
and filters out entries having an idle time less than or equal to
<code>
<min-idle-time>
</code>
.
The maximum number of pending entries that the command scans is the product of multiplying
<code>
<count>
</code>
's value by 10 (hard-coded).
It is possible, therefore, that the number of entries claimed will be less than the specified value.
</p>
<p>
The optional
<code>
JUSTID
</code>
argument changes the reply to return just an array of IDs of messages successfully claimed, without returning the actual message.
Using this option means the retry counter is not incremented.
</p>
<p>
The command returns the claimed entries as an array. It also returns a stream ID intended for cursor-like use as the
<code>
<start>
</code>
argument for its subsequent call.
When there are no remaining PEL entries, the command returns the special
<code>
0-0
</code>
ID to signal completion.
However, note that you may want to continue calling
<code>
XAUTOCLAIM
</code>
even after the scan is complete with the
<code>
0-0
</code>
as
<code>
<start>
</code>
ID, because enough time passed, so older pending entries may now be eligible for claiming.
</p>
<p>
Note that only messages that are idle longer than
<code>
<min-idle-time>
</code>
are claimed, and claiming a message resets its idle time.
This ensures that only a single consumer can successfully claim a given pending message at a specific instant of time and trivially reduces the probability of processing the same message multiple times.
</p>
<p>
While iterating the PEL, if
<code>
XAUTOCLAIM
</code>
stumbles upon a message which doesn't exist in the stream anymore (either trimmed or deleted by
<a href="/docs/latest/commands/xdel/">
<code>
XDEL
</code>
</a>
) it does not claim it, and deletes it from the PEL in which it was found. This feature was introduced in Redis 7.0.
These message IDs are returned to the caller as a part of
<code>
XAUTOCLAIM
</code>
s reply.
</p>
<p>
Lastly, claiming a message with
<code>
XAUTOCLAIM
</code>
also increments the attempted deliveries count for that message, unless the
<code>
JUSTID
</code>
option has been specified (which only delivers the message ID, not the message itself).
Messages that cannot be processed for some reason - for example, because consumers systematically crash when processing them - will exhibit high attempted delivery counts that can be detected by monitoring.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>> XAUTOCLAIM mystream mygroup Alice 3600000 0-0 COUNT 25
1) "0-0"
2) 1) 1) "1609338752495-0"
2) 1) "field"
2) "value"
3) (empty array)
</code></pre>
<p>
In the above example, we attempt to claim up to 25 entries that are pending and idle (not having been acknowledged or claimed) for at least an hour, starting at the stream's beginning.
The consumer "Alice" from the "mygroup" group acquires ownership of these messages.
Note that the stream ID returned in the example is
<code>
0-0
</code>
, indicating that the entire stream was scanned.
We can also see that
<code>
XAUTOCLAIM
</code>
did not stumble upon any deleted messages (the third reply element is an empty array).
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<p>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
, specifically, an array with three elements:
</p>
<ol>
<li>
A stream ID to be used as the
<em>
start
</em>
argument for the next call to XAUTOCLAIM.
</li>
<li>
An
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
containing all the successfully claimed messages in the same format as
<code>
XRANGE
</code>
.
</li>
<li>
An
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
containing message IDs that no longer exist in the stream, and were deleted from the PEL in which they were found.
</li>
</ol>
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.0.0: Added an element to the reply array, containing deleted entries the command cleared from the PEL
</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/xautoclaim/"/>
<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/postgresql/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Prepare PostgreSQL for RDI
</h1>
<p class="text-lg -mt-5 mb-10">
Prepare PostgreSQL databases to work with RDI
</p>
<p>
PostgreSQL supports several
<a href="https://wiki.postgresql.org/wiki/Logical_Decoding_Plugins">
logical decoding plug-ins
</a>
to enable CDC. If you don't want to use the native
<code>
pgoutput
</code>
logical replication stream support
then you must install your preferred plug-in into the PostgreSQL server. Once you have done this,
you must enable a replication slot, and configure a user with privileges to perform the replication.
</p>
<p>
If you are using a service like
<a href="https://www.heroku.com/postgres">
Heroku Postgres
</a>
to host
your database then this might restrict the plug-ins you can use. If you can't use your preferred
plug-in then could try the
<code>
pgoutput
</code>
decoder if you are using PostgreSQL 10 or above.
If this doesn't work for you then you won't be able to use RDI with your database.
</p>
<h3 id="amazon-rds-for-postgresql">
Amazon RDS for PostgreSQL
</h3>
<p>
Follow the steps below to enable CDC with
<a href="https://aws.amazon.com/rds/postgresql/">
Amazon RDS for PostgreSQL
</a>
:
</p>
<ol>
<li>
<p>
Set the instance parameter
<code>
rds.logical_replication
</code>
to 1.
</p>
</li>
<li>
<p>
Check that the
<code>
wal_level
</code>
parameter is set to
<code>
logical
</code>
by running the query
<code>
SHOW wal_level
</code>
as the database RDS master user. The parameter might not have this value in multi-zone replication
setups. You can't change the value manually but it should change automatically when you set the
<code>
rds.logical_replication
</code>
parameter to 1. If it doesn't change then you probably just need to
restart your database instance. You can restart manually or wait until a restart occurs
during your maintenance window.
</p>
</li>
<li>
<p>
Set the Debezium
<code>
plugin.name
</code>
parameter to
<code>
pgoutput
</code>
.
</p>
</li>
<li>
<p>
Initiate logical replication from an AWS account that has the
<code>
rds_replication
</code>
role. The role grants
permissions to manage logical slots and to stream data using logical slots. By default, only the master user account on AWS has the
<code>
rds_replication
</code>
role on Amazon RDS, but if you have administrator privileges,
you can grant the role to other accounts using a query 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="k">GRANT</span><span class="w"> </span><span class="n">rds_replication</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="o"><</span><span class="n">my_user</span><span class="o">></span><span class="w">
</span></span></span></code></pre>
</div>
<p>
To enable accounts other than the master account to create an initial snapshot, you must grant
<code>
SELECT
</code>
permission to the accounts on the tables to be captured. See the documentation about
<a href="https://www.postgresql.org/docs/current/logical-replication-security.html">
security for PostgreSQL logical replication
</a>
for more information.
</p>
</li>
</ol>
<h2 id="install-the-logical-decoding-output-plug-in">
Install the logical decoding output plug-in
</h2>
<p>
As of PostgreSQL 9.4, the only way to read changes to the write-ahead-log is to
<a href="https://debezium.io/documentation/reference/2.6/postgres-plugins.html">
install a logical decoding output plug-in
</a>
.
These plug-ins are written in C using PostgreSQL-specific APIs, as described in the
<a href="https://www.postgresql.org/docs/current/logicaldecoding-output-plugin.html">
PostgreSQL documentation
</a>
.
The PostgreSQL connector uses one of Debezium’s supported logical decoding
plug-ins to receive change events from the database in either the default
<a href="https://github.com/postgres/postgres/blob/master/src/backend/replication/pgoutput/pgoutput.c">
<code>
pgoutput
</code>
</a>
format (supplied with PostgreSQL) or the
<a href="https://github.com/protocolbuffers/protobuf">
<code>
Protobuf
</code>
</a>
format.
See the
<a href="https://github.com/debezium/postgres-decoderbufs">
decoderbufs Protobuf plug-in documentation
</a>
for more details about how to compile it and also its requirements and limitations.
</p>
<p>
For simplicity, Debezium also provides a container image that compiles and installs the plug-ins
on top of the upstream PostgreSQL server image. Use this image as an example of the steps
involved in the installation.
</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 Debezium logical decoding plug-ins have been tested on Linux machines, but if you are
using Windows or other operating systems, the installation steps might be different from
those listed here.
</div>
</div>
<h3 id="plug-in-differences">
Plug-in differences
</h3>
<p>
Plug-ins don't all behave in exactly the same way. All of them refresh information about
the database schema when they detect that it has changed, but the
<code>
pgoutput
</code>
plug-in is
more "eager" than some other plug-ins to do this. For example,
<code>
pgoutput
</code>
will refresh
when it detects a change to the default value of a column but other plug-ins won't
notice this until another, more significant change happens (such as adding a new table
column).
</p>
<p>
The Debezium project maintains a
<a href="https://github.com/debezium/debezium/blob/main/debezium-connector-postgres/src/test/java/io/debezium/connector/postgresql/DecoderDifferences.java">
Java class
</a>
that tracks the known differences between plug-ins.
</p>
<h2 id="configure-the-postgresql-server">
Configure the PostgreSQL server
</h2>
<p>
If you want to use a logical decoding plug-in other than the default
<code>
pgoutput
</code>
then
you must first configure it in the
<code>
postgresql.conf
</code>
file. Set the
<code>
shared_preload_libraries
</code>
parameter to load your plug-in at startup. For example, to load the
<code>
decoderbufs
</code>
plug-in, you would add the following line:
</p>
<pre tabindex="0"><code># MODULES
shared_preload_libraries = 'decoderbufs'
</code></pre>
<p>
Add the line below to configure the replication slot (for any plug-in).
This instructs the server to use logical decoding with the write-ahead log.
</p>
<pre tabindex="0"><code># REPLICATION
wal_level = logical
</code></pre>
<p>
You can also set other PostgreSQL streaming replication parameters if you need them.
For example, you can use
<code>
max_wal_senders
</code>
and
<code>
max_replication_slots
</code>
to increase
the number of connectors that can access the sending server concurrently,
and
<code>
wal_keep_size
</code>
to limit the maximum WAL size that a replication slot retains.
The
<a href="https://www.postgresql.org/docs/current/runtime-config-replication.html#RUNTIME-CONFIG-REPLICATION-SENDER">
configuration parameters
</a>
documentation describes all the parameters you can use.
</p>
<p>
PostgreSQL’s logical decoding uses replication slots. These are guaranteed to retain all the WAL
segments that Debezium needs even when Debezium suffers an outage. You should monitor replication
slots carefully to avoid excessive disk consumption and other conditions such as catalog bloat that can arise
if a replication slot is used infrequently. See the PostgreSQL documentation about
<a href="https://www.postgresql.org/docs/current/warm-standby.html#STREAMING-REPLICATION-SLOTS">
replication slots
</a>
for more information.
If you are using a
<code>
synchronous_commit
</code>
setting other than
<code>
on
</code>
, then you should set
<code>
wal_writer_delay
</code>
to a value of about 10 milliseconds to ensure a low latency for change events. If you don't set this then
the default value of about 200 milliseconds will apply.
</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 guide summarizes the operation of the PostgreSQL write-ahead log, but we strongly
recommend you consult the
<a href="https://www.postgresql.org/docs/current/wal-configuration.html">
PostgreSQL write-ahead log
</a>
documentation to get a better understanding.
</div>
</div>
<h2 id="set-up-permissions">
Set up permissions
</h2>
<p>
The Debezium connector needs a database user that has the REPLICATION and LOGIN roles so that it
can perform replications. By default, a superuser has these roles but for security reasons, you
should give the minimum necessary permissions to the Debezium user rather than full superuser
permissions.
</p>
<p>
If you have administrator privileges then you can create a role for your Debezium user
using a query like the following. Note that these are the
<em>
minimum
</em>
permissions the user
needs to perform replications, but you might also need to grant other permissions.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">CREATE</span><span class="w"> </span><span class="k">ROLE</span><span class="w"> </span><span class="o"><</span><span class="n">name</span><span class="o">></span><span class="w"> </span><span class="n">REPLICATION</span><span class="w"> </span><span class="n">LOGIN</span><span class="p">;</span><span class="w">
</span></span></span></code></pre>
</div>
<h2 id="set-privileges-for-debezium-to-create-postgresql-publications-with-pgoutput">
Set privileges for Debezium to create PostgreSQL publications with
<code>
pgoutput
</code>
</h2>
<p>
The Debezium user needs specific permissions to work with the
<code>
pgoutput
</code>
plug-in.
The plug-in captures change events from the
<a href="https://www.postgresql.org/docs/current/logical-replication-publication.html">
<em>
publications
</em>
</a>
that PostgreSQL produces for your chosen source tables. A publication contains change events from
one or more tables that are filtered using criteria from a
<em>
publication specification
</em>
.
</p>
<p>
If you have administrator privileges, you can create the publication specification
manually or you can grant the Debezium user the privileges to create the specification
automatically. The required privileges are:
</p>
<ul>
<li>
Replication privileges in the database to add the table to a publication.
</li>
<li>
<code>
CREATE
</code>
privileges on the database to add publications.
</li>
<li>
<code>
SELECT
</code>
privileges on the tables to copy the initial table data. Table owners
automatically have
<code>
SELECT
</code>
permission for the table.
</li>
</ul>
<p>
To add a table to a publication, the user must be an owner of the table. However, in
this case, the source table already exists, so you must use a PostgreSQL replication
group to share ownership between the Debezium user and the original owner. Configure
the replication group using the following commands:
</p>
<ol>
<li>
<p>
Create the replication group (the name
<code>
replication_group
</code>
here is
just an example):
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">CREATE</span><span class="w"> </span><span class="k">ROLE</span><span class="w"> </span><span class="n">replication_group</span><span class="p">;</span><span class="w">
</span></span></span></code></pre>
</div>
</li>
<li>
<p>
Add the original owner of the table to the group:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">GRANT</span><span class="w"> </span><span class="n">replication_group</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">original_owner</span><span class="p">;</span><span class="w">
</span></span></span></code></pre>
</div>
</li>
<li>
<p>
Add the Debezium replication user to the group:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">GRANT</span><span class="w"> </span><span class="n">replication_group</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">replication_user</span><span class="p">;</span><span class="w">
</span></span></span></code></pre>
</div>
</li>
<li>
<p>
Transfer ownership of the table to
<code>
replication_group
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">ALTER</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="k">OWNER</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">replication_group</span><span class="p">;</span><span class="w">
</span></span></span></code></pre>
</div>
</li>
</ol>
<p>
You must also set the value of the
<code>
publication.autocreate.mode
</code>
parameter to
<code>
filtered
</code>
to allow Debezium to specify the publication configuration. See the
<a href="https://debezium.io/documentation/reference/2.6/connectors/postgresql.html#postgresql-publication-autocreate-mode">
Debezium documentation for
<code>
publication.autocreate.mode
</code>
</a>
to learn more about this setting.
</p>
<h2 id="configure-postgresql-for-replication-with-the-debezium-connector-host">
Configure PostgreSQL for replication with the Debezium connector host
</h2>
<p>
You must configure the database to allow replication with the host that runs
the PostgreSQL Debezium connector. To do this, add an entry to the
host-based authentication file,
<code>
pg_hba.conf
</code>
, for each client that needs to
use replication. For example, to enable replication for
<code>
<youruser>
</code>
locally,
on the server machine, you would add a line like the following:
</p>
<pre tabindex="0"><code>local replication <youruser> trust
</code></pre>
<p>
To allow
<code>
<youruser>
</code>
on localhost to receive replication changes using IPV4,
add the line:
</p>
<pre tabindex="0"><code>host replication <youruser> 127.0.0.1/32 trust
</code></pre>
<p>
To allow
<code>
<youruser>
</code>
on localhost to receive replication changes using IPV6,
add the line:
</p>
<pre tabindex="0"><code>host replication <youruser> ::1/128 trust
</code></pre>
<p>
Find out more from the PostgreSQL pages about
<a href="https://www.postgresql.org/docs/10/auth-pg-hba-conf.html">
<code>
pg_hba.conf
</code>
</a>
and
<a href="https://www.postgresql.org/docs/current/datatype-net-types.html">
network address types
</a>
.
</p>
<h2 id="supported-postgresql-topologies">
Supported PostgreSQL topologies
</h2>
<p>
You can use the Debezium PostgreSQL connector with a standalone PostgreSQL server or
with a cluster of servers.
For versions 12 and below, PostgreSQL supports logical replication slots on only primary servers.
This means that Debezium can only connect to a primary server for CDC and the connection will
stop if this server fails. If the same server is promoted to primary when service resumes
then you can simply restart the Debezium connector. However, if a different server is
promoted to primary, then you must reconfigure Debezium to use the new server
before restarting. Also, make sure the new server has the correct plug-in and configuration
for Debezium.
</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/integrate/redis-data-integration/data-pipelines/prepare-dbs/postgresql/"/>
<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/ft.cursor-read/.html | <section class="prose w-full py-12">
<h1 class="command-name">
FT.CURSOR READ
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FT.CURSOR READ index cursor_id [COUNT read_size]
</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/interact/search-and-query">
Search 1.1.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>
Read next results from an existing cursor
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<p>
See
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations#cursor-api">
Cursor API
</a>
for more details.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
index
</code>
</summary>
<p>
is index name.
</p>
</details>
<details open="">
<summary>
<code>
cursor_id
</code>
</summary>
<p>
is id of the cursor.
</p>
</details>
<details open="">
<summary>
<code>
[COUNT read_size]
</code>
</summary>
<p>
is number of results to read. This parameter overrides
<code>
COUNT
</code>
specified in
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
.
</p>
</details>
<h2 id="return">
Return
</h2>
<p>
FT.CURSOR READ returns an array reply where each row is an array reply and represents a single aggregate result.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Read next results from a cursor
</b>
</summary>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> FT.CURSOR READ idx <span class="m">342459320</span> COUNT <span class="m">50</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ft.cursor-del/">
<code>
FT.CURSOR DEL
</code>
</a>
|
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<p>
<a href="/docs/latest/develop/interact/search-and-query/">
RediSearch
</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/ft.cursor-read/"/>
<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/tdigest.info/.html | <section class="prose w-full py-12">
<h1 class="command-name">
TDIGEST.INFO
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TDIGEST.INFO 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.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>
Returns information and statistics about a t-digest sketch.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for an existing t-digest sketch.
</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 sketch (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>
Compression
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
The compression (controllable trade-off between accuracy and memory consumption) of the sketch
</td>
</tr>
<tr>
<td>
<code>
Capacity
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Size of the buffer used for storing the centroids and for the incoming unmerged observations
</td>
</tr>
<tr>
<td>
<code>
Merged nodes
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of merged observations
</td>
</tr>
<tr>
<td>
<code>
Unmerged nodes
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of buffered nodes (uncompressed observations)
</td>
</tr>
<tr>
<td>
<code>
Merged weight
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Weight of values of the merged nodes
</td>
</tr>
<tr>
<td>
<code>
Unmerged weight
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Weight of values of the unmerged nodes (uncompressed observations)
</td>
</tr>
<tr>
<td>
<code>
Observations
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of observations added to the sketch
</td>
</tr>
<tr>
<td>
<code>
Total compressions
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of times this sketch compressed data together
</td>
</tr>
<tr>
<td>
<code>
Memory usage
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of bytes allocated for the sketch
</td>
</tr>
</tbody>
</table>
<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> TDIGEST.CREATE t
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.ADD t <span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.INFO t
</span></span><span class="line"><span class="cl"> 1<span class="o">)</span> Compression
</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">100</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> Capacity
</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">610</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> Merged nodes
</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> Unmerged nodes
</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">5</span>
</span></span><span class="line"><span class="cl"> 9<span class="o">)</span> Merged weight
</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> Unmerged weight
</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">5</span>
</span></span><span class="line"><span class="cl">13<span class="o">)</span> Observations
</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">5</span>
</span></span><span class="line"><span class="cl">15<span class="o">)</span> Total compressions
</span></span><span class="line"><span class="cl">16<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">17<span class="o">)</span> Memory usage
</span></span><span class="line"><span class="cl">18<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">9768</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/tdigest.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/operate/rc/changelog/2023/november-2023/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Cloud changelog (November 2023)
</h1>
<p class="text-lg -mt-5 mb-10">
New features, enhancements, and other changes added to Redis Cloud during November 2023.
</p>
<h2 id="new-features">
New features
</h2>
<h3 id="new-fixed-plans">
New Fixed plans
</h3>
<p>
Redis is updating our
<a href="/docs/latest/operate/rc/databases/create-database/create-essentials-database/">
Fixed subscriptions
</a>
on Redis Cloud. These plans offer increased capacity at lower prices compared to legacy plans.
</p>
<p>
See
<a href="/docs/latest/operate/rc/databases/create-database/create-essentials-database/#fixed-plans">
Fixed plan subscription tiers
</a>
for an updated list of all Fixed plans.
</p>
<h3 id="redis-72-fixed-region-support">
Redis 7.2 Fixed region support
</h3>
<p>
You can now use Redis 7.2 on
<a href="/docs/latest/operate/rc/databases/create-database/create-essentials-database/">
Fixed subscriptions
</a>
in
<code>
us-east-1
</code>
on Amazon Web Services. New Fixed subscriptions created in
<code>
us-east-1
</code>
will use Redis 7.2, and existing subscriptions will continue to use Redis 6.2.
</p>
<p>
Redis 7.2 introduces several changes to existing Redis commands; see the
<a href="/docs/latest/operate/rc/changelog/2023/june-2023/#redis-72-breaking-changes">
list of breaking changes
</a>
published in June's changelog for more details.
</p>
<h2 id="deprecations">
Deprecations
</h2>
<h3 id="heroku-add-on-free-database-limit">
Heroku add-on free database limit
</h3>
<p>
Heroku add-ons for
<a href="https://elements.heroku.com/addons/rediscloud">
Redis Cloud
</a>
and
<a href="https://elements.heroku.com/addons/memcachedcloud">
Memcached Cloud
</a>
are limited to one free database per Heroku account. As of November 1st, users will not be able to add a new free database if they already have one or more free databases. There will be no impact to existing free and paid databases.
</p>
<p>
Additionally, Heroku Review and CI Apps will provision a 100 MB database for the
<a href="https://elements.heroku.com/addons/rediscloud">
Redis Cloud
</a>
and
<a href="https://elements.heroku.com/addons/memcachedcloud">
Memcached Cloud
</a>
add-on selections.
</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/changelog/2023/november-2023/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Access control
</h1>
<p class="text-lg -mt-5 mb-10">
An overview of access control in Redis Enterprise Software.
</p>
<p>
Redis Enterprise Software lets you use role-based access control (RBAC) to manage users' access privileges. RBAC requires you to do the following:
</p>
<ol>
<li>
<p>
Create roles and define each role's access privileges.
</p>
</li>
<li>
<p>
Create users and assign roles to them. The assigned role determines the user's access privileges.
</p>
</li>
</ol>
<h2 id="cluster-access-versus-database-access">
Cluster access versus database access
</h2>
<p>
Redis Enterprise allows two separate paths of access:
</p>
<ul>
<li>
<p>
<strong>
Cluster access
</strong>
allows performing management-related actions, such as creating databases and viewing statistics.
</p>
</li>
<li>
<p>
<strong>
Database access
</strong>
allows performing data-related actions, like reading and writing data in a database.
</p>
</li>
</ul>
<p>
You can grant cluster access, database access, or both to each role. These roles let you differentiate between users who can access databases and users who can access cluster management, according to your organization's security needs.
</p>
<p>
The following diagram shows three different options for roles and users:
</p>
<a href="/docs/latest/images/rs/rbac-diagram.png" sdata-lightbox="/images/rs/rbac-diagram.png">
<img alt="Role-based access control diagram." src="/docs/latest/images/rs/rbac-diagram.png"/>
</a>
<ul>
<li>
<p>
Role A was created with permission to access the cluster and perform management-related actions. Because user A was assigned role A, they can access the cluster but cannot access databases.
</p>
</li>
<li>
<p>
Role B was created with permission to access one or more databases and perform data-related actions. Because user B was assigned role B, they cannot access the cluster but can access databases.
</p>
</li>
<li>
<p>
Role C was created with cluster access and database access permissions. Because user C was assigned role C, they can access the cluster and databases.
</p>
</li>
</ul>
<h2 id="default-database-access">
Default database access
</h2>
<p>
When you create a database,
<a href="/docs/latest/operate/rs/security/access-control/manage-users/default-user/">
default user access
</a>
is enabled automatically.
</p>
<p>
If you set up role-based access controls for your database and don't require compatibility with versions earlier than Redis 6, you can
<a href="/docs/latest/operate/rs/security/access-control/manage-users/default-user/">
deactivate the default user
</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">
Warning:
</div>
Before you
<a href="/docs/latest/operate/rs/security/access-control/manage-users/default-user/#deactivate-default-user">
deactivate default user access
</a>
, make sure the role associated with the database is
<a href="/docs/latest/operate/rs/security/access-control/create-users/#assign-roles-to-users">
assigned to a user
</a>
. Otherwise, the database will be inaccessible.
</div>
</div>
<h2 id="more-info">
More info
</h2>
<nav>
<a href="/docs/latest/operate/rs/security/access-control/create-users/">
Create users
</a>
<p>
Create users and assign access control roles.
</p>
<a href="/docs/latest/operate/rs/security/access-control/create-cluster-roles/">
Create roles with cluster access only
</a>
<p>
Create roles with cluster access only.
</p>
<a href="/docs/latest/operate/rs/security/access-control/create-db-roles/">
Create roles with database access only
</a>
<p>
Create roles with database access only.
</p>
<a href="/docs/latest/operate/rs/security/access-control/create-combined-roles/">
Create roles with combined access
</a>
<p>
Create roles with both cluster and database access.
</p>
<a href="/docs/latest/operate/rs/security/access-control/redis-acl-overview/">
Overview of Redis ACLs in Redis Enterprise Software
</a>
<p>
An overview of Redis ACLs, syntax, and ACL command support in Redis Enterprise Software.
</p>
<a href="/docs/latest/operate/rs/security/access-control/manage-users/">
Manage user security
</a>
<p>
Manage user account security settings.
</p>
<a href="/docs/latest/operate/rs/security/access-control/manage-passwords/">
Set password policies
</a>
<p>
Set password policies.
</p>
<a href="/docs/latest/operate/rs/security/access-control/ldap/">
LDAP authentication
</a>
<p>
Describes how Redis Enterprise Software integrates LDAP authentication and authorization. Also describes how to enable LDAP for your deployment of Redis Enterprise Software.
</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/operate/rs/security/access-control/"/>
<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/search/config/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Search and query configuration compatibility with Redis Enterprise
</h1>
<p class="text-lg -mt-5 mb-10">
Search and query configuration settings supported by Redis Enterprise Software and Redis Cloud.
</p>
<p>
To configure RediSearch in
<a href="/docs/latest/operate/rs/">
Redis Enterprise Software
</a>
or
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
, use one of the following methods instead of
<a href="/docs/latest/commands/ft.config-set">
<code>
FT.CONFIG SET
</code>
</a>
.
</p>
<h2 id="configure-search-in-redis-cloud">
Configure search in Redis Cloud
</h2>
<p>
For Redis Cloud:
</p>
<ul>
<li>
<p>
<em>
Flexible or Annual
<a href="/docs/latest/operate/rc/subscriptions/">
subscriptions
</a>
</em>
: contact
<a href="https://redis.com/company/support/">
support
</a>
to request a configuration change.
</p>
</li>
<li>
<p>
<em>
Free or Fixed subscriptions
</em>
: you cannot change RediSearch configuration.
</p>
</li>
</ul>
<h2 id="configure-search-in-redis-software">
Configure search in Redis Software
</h2>
<p>
For Redis Enterprise Software, use one of the following methods:
</p>
<ul>
<li>
<p>
Cluster Manager UI:
</p>
<ol>
<li>
<p>
From the
<strong>
Databases
</strong>
list, select the database, then click
<strong>
Configuration
</strong>
.
</p>
</li>
<li>
<p>
Select the
<strong>
Edit
</strong>
button.
</p>
</li>
<li>
<p>
In the
<strong>
Capabilities
</strong>
section, click
<strong>
Parameters
</strong>
.
</p>
</li>
<li>
<p>
Enter the setting name and setting value in the
<strong>
RediSearch
</strong>
box.
</p>
<p>
In the
<strong>
Query Performance Factor
</strong>
section, you can configure settings to improve query performance. See
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/query-performance-factor/">
Configure the query performance factor for Redis Query Engine in Redis Enterprise
</a>
for more information.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/rs-config-search-params.png" sdata-lightbox="/images/rs/screenshots/databases/rs-config-search-params.png">
<img alt="The Parameters dialog includes sections to edit RediSearch settings and the Query Performance Factor settings." src="/docs/latest/images/rs/screenshots/databases/rs-config-search-params.png"/>
</a>
</li>
<li>
<p>
After you finish editing the module's configuration parameters, click
<strong>
Done
</strong>
to close the parameter editor.
</p>
</li>
<li>
<p>
Click
<strong>
Save
</strong>
.
</p>
</li>
</ol>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/tune/#tune-db">
<code>
rladmin tune db
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin tune db db:<ID<span class="p">|</span>name> module_name search <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> module_config_params <span class="s2">"setting-name setting-value"</span>
</span></span></code></pre>
</div>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/rest-api/requests/modules/config/">
Configure module
</a>
REST API request:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/modules/config/bdb/<ID>
</span></span><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"modules"</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="s2">"module_name"</span>: <span class="s2">"search"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"module_args"</span>: <span class="s2">"setting-name setting-value"</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><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
</li>
</ul>
<h2 id="configuration-settings">
Configuration settings
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
Setting
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
Notes
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
CONCURRENT_WRITE_MODE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: Not enabled
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
CURSOR_MAX_IDLE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 300000
</td>
</tr>
<tr>
<td style="text-align:left">
CURSOR_READ_SIZE
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 1000
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
DEFAULT_DIALECT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 1
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
EXTLOAD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: None
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
FORK_GC_CLEAN_THRESHOLD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 100
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
FORK_GC_RETRY_INTERVAL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 5
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
FORK_GC_RUN_INTERVAL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 30
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
FRISOINI
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: Not set
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
GC_POLICY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: FORK
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
GC_SCANSIZE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 100
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
MAXAGGREGATERESULTS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Redis Enterprise default: Unlimited
<br/>
<br/>
Redis Cloud defaults:
<br/>
• Flexible & Annual: Unlimited
<br/>
• Free & Fixed: 10000
<br/>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
MAXDOCTABLESIZE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 1000000
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
MAXPREFIXEXPANSIONS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 200
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
MAXSEARCHRESULTS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Redis Enterprise default: 1000000
<br/>
<br/>
Redis Cloud defaults:
<br/>
• Flexible & Annual: 1000000
<br/>
• Free & Fixed: 10000
<br/>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
MINPREFIX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 2
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
MINSTEMLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 2
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
NOGC
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: Not set
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
ON_TIMEOUT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: RETURN
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
OSS_GLOBAL_PASSWORD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
<nobr>
❌ Flexible & Annual
</nobr>
</span>
<nobr>
<br/>
<span title="Not supported">
</span>
</nobr>
<nobr>
❌ Free & Fixed
</nobr>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
PARTIAL_INDEXED_DOCS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 0
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
TIMEOUT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Redis Enterprise default: 500
<br/>
<br/>
Redis Cloud defaults:
<br/>
• Flexible & Annual: 500
<br/>
• Free & Fixed: 100
<br/>
</td>
</tr>
<tr>
<td style="text-align:left">
UNION_ITERATOR_HEAP
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
UPGRADE_INDEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: No default index name
</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/search/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/7.4/databases/active-active/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Active-Active geo-distributed Redis
</h1>
<p class="text-lg -mt-5 mb-10">
Overview of the Active-Active database in Redis Enterprise Software
</p>
<p>
In Redis Enterprise, Active-Active geo-distribution is based on
<a href="https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type">
CRDT technology
</a>
.
The Redis Enterprise implementation of CRDT is called an Active-Active database (formerly known as CRDB).
With Active-Active databases, applications can read and write to the same data set from different geographical locations seamlessly and with latency less than one millisecond (ms),
without changing the way the application connects to the database.
</p>
<p>
Active-Active databases also provide disaster recovery and accelerated data read-access for geographically distributed users.
</p>
<h2 id="high-availability">
High availability
</h2>
<p>
The
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/">
high availability
</a>
that Active-Active replication provides is built upon a number of Redis Enterprise Software features (such as
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/clustering/">
clustering
</a>
,
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/replication/">
replication
</a>
, and
<a href="/docs/latest/operate/rs/7.4/databases/configure/replica-ha/">
replica HA
</a>
) as well as some features unique to Active-Active (
<a href="#multi-primary-replication/">
multi-primary replication
</a>
,
<a href="#conflict-resolution/">
automatic conflict resolution
</a>
, and
<a href="#strong-eventual-consistency/">
strong eventual consistency
</a>
).
</p>
<p>
Clustering and replication are used together in Active-Active databases to distribute multiple copies of the dataset across multiple nodes and multiple clusters. As a result, a node or cluster is less likely to become a single point of failure. If a primary node or primary shard fails, a replica is automatically promoted to primary. To avoid having one node hold all copies of certain data, the
<a href="/docs/latest/operate/rs/7.4/databases/configure/replica-ha/">
replica HA
</a>
feature (enabled by default) automatically migrates replica shards to available nodes.
</p>
<h2 id="multi-primary-replication">
Multi-primary replication
</h2>
<p>
In Redis Enterprise Software, replication copies data from primary shards to replica shards. Active-Active geo-distributed replication also copies both primary and replica shards to other clusters. Each Active-Active database needs to span at least two clusters; these are called participating clusters.
</p>
<p>
Each participating cluster hosts an instance of your database, and each instance has its own primary node. Having multiple primary nodes means you can connect to the proxy in any of your participating clusters. Connecting to the closest cluster geographically enables near-local latency. Multi-primary replication (previously referred to as multi-master replication) also means that your users still have access to the database if one of the participating clusters fails.
</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>
Active-Active databases do not replicate the entire database, only the data.
Database configurations, LUA scripts, and other support info are not replicated.
</div>
</div>
<h2 id="syncer">
Syncer
</h2>
<p>
Keeping multiple copies of the dataset consistent across multiple clusters is no small task. To achieve consistency between participating clusters, Redis Active-Active replication uses a process called the
<a href="/docs/latest/operate/rs/7.4/databases/active-active/syncer/">
syncer
</a>
.
</p>
<p>
The syncer keeps a
<a href="/docs/latest/operate/rs/7.4/databases/active-active/manage/#replication-backlog/">
replication backlog
</a>
, which stores changes to the dataset that the syncer sends to other participating clusters. The syncer uses partial syncs to keep replicas up to date with changes, or a full sync in the event a replica or primary is lost.
</p>
<h2 id="conflict-resolution">
Conflict resolution
</h2>
<p>
Because you can connect to any participating cluster to perform a write operation, concurrent and conflicting writes are always possible. Conflict resolution is an important part of the Active-Active technology. Active-Active databases only use
<a href="https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type">
conflict-free replicated data types (CRDTs)
</a>
. These data types provide a predictable conflict resolution and don't require any additional work from the application or client side.
</p>
<p>
When developing with CRDTs for Active-Active databases, you need to consider some important differences. See
<a href="/docs/latest/operate/rs/7.4/databases/active-active/develop/">
Develop applications with Active-Active databases
</a>
for related information.
</p>
<h2 id="strong-eventual-consistency">
Strong eventual consistency
</h2>
<p>
Maintaining strong consistency for replicated databases comes with tradeoffs in scalability and availability. Redis Active-Active databases use a strong eventual consistency model, which means that local values may differ across replicas for short periods of time, but they all eventually converge to one consistent state. Redis uses vector clocks and the CRDT conflict resolution to strengthen consistency between replicas. You can also enable the causal consistency feature to preserve the order of operations as they are synchronized among replicas.
</p>
<p>
Other Redis Enterprise Software features can also be used to enhance the performance, scalability, or durability of your Active-Active database. These include
<a href="/docs/latest/operate/rs/7.4/databases/configure/database-persistence/">
data persistence
</a>
,
<a href="/docs/latest/operate/rs/7.4/databases/configure/proxy-policy/">
multiple active proxies
</a>
,
<a href="/docs/latest/operate/rs/7.4/databases/active-active/synchronization-mode/">
distributed synchronization
</a>
,
<a href="/docs/latest/operate/rs/7.4/databases/configure/oss-cluster-api/">
OSS Cluster API
</a>
, and
<a href="/docs/latest/operate/rs/7.4/clusters/configure/rack-zone-awareness/">
rack-zone awareness
</a>
.
</p>
<h2 id="next-steps">
Next steps
</h2>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/planning/">
Plan your Active-Active deployment
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/get-started/">
Get started with Active-Active
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/create/">
Create an Active-Active database
</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/operate/rs/7.4/databases/active-active/"/>
<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/linsert/.html | <section class="prose w-full py-12">
<h1 class="command-name">
LINSERT
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">LINSERT key <BEFORE | AFTER> pivot element</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.2.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 number of elements to traverse before seeing the value pivot. This means that inserting somewhere on the left end on the list (head) can be considered O(1) and inserting somewhere on the right end (tail) is O(N).
</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>
Inserts
<code>
element
</code>
in the list stored at
<code>
key
</code>
either before or after the reference
value
<code>
pivot
</code>
.
</p>
<p>
When
<code>
key
</code>
does not exist, it is considered an empty list and no operation is
performed.
</p>
<p>
An error is returned when
<code>
key
</code>
exists but does not hold a list value.
</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> RPUSH mylist "Hello"
(integer) 1
redis> RPUSH mylist "World"
(integer) 2
redis> LINSERT mylist BEFORE "World" "There"
(integer) 3
redis> LRANGE mylist 0 -1
1) "Hello"
2) "There"
3) "World"
</pre>
<div class="prompt" style="">
<span>
redis>
</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>
: the list length after a successful insert operation.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
0
</code>
when the key doesn't exist.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
-1
</code>
when the pivot wasn't found.
</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/linsert/"/>
<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/redis-for-vscode/release-notes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis for VS Code release notes
</h1>
<p>
Here are the most recent changes for Redis for VS Code:
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
Version (Date)
</th>
<th style="text-align:left">
Release notes
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
v1.0.0 (September 2024)
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/tools/redis-for-vscode/release-notes/v1.0.0/">
Redis for VS Code v1.0.0, September 2024
</a>
</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/develop/tools/redis-for-vscode/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/rs/clusters/maintenance-mode/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Maintenance mode for cluster nodes
</h1>
<p class="text-lg -mt-5 mb-10">
Prepare a cluster node for maintenance.
</p>
<p>
Use maintenance mode to prevent data loss during hardware patching or operating system maintenance on Redis Enterprise servers. When maintenance mode is on, all shards move off of the node under maintenance and migrate to another available node.
</p>
<h2 id="activate-maintenance-mode">
Activate maintenance mode
</h2>
<p>
When you activate maintenance mode, Redis Enterprise does the following:
</p>
<ol>
<li>
<p>
Checks whether a shut down of the node will cause quorum loss. If so, maintenance mode will not turn on.
</p>
<p>
Maintenance mode does not protect against quorum loss. If you activate maintenance mode for the majority of nodes in a cluster and restart them simultaneously, quorum is lost, which can lead to data loss.
</p>
</li>
<li>
<p>
If no maintenance mode snapshots already exist or if you use
<code>
overwrite_snapshot
</code>
when you activate maintenance mode, Redis Enterprise creates a new node snapshot that records the node's shard and endpoint configuration.
</p>
</li>
<li>
<p>
Marks the node as a quorum node to prevent shards and endpoints from migrating to it.
</p>
<p>
At this point,
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/">
<code>
rladmin status
</code>
</a>
displays the node's shards field in yellow, which indicates that shards cannot migrate to the node.
</p>
<a href="/docs/latest/images/rs/maintenance_mode.png" sdata-lightbox="/images/rs/maintenance_mode.png">
<img src="/docs/latest/images/rs/maintenance_mode.png"/>
</a>
</li>
<li>
<p>
Migrates shards and binds endpoints to other nodes, when space is available.
</p>
</li>
</ol>
<p>
Maintenance mode does not demote a master node by default. The cluster elects a new master node when the original master node restarts.
</p>
<p>
Add the
<code>
demote_node
</code>
option to the
<code>
rladmin
</code>
command to
<a href="#demote-a-master-node">
demote a master node
</a>
when you activate maintenance mode.
</p>
<p>
To activate maintenance mode for a node, run the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode on overwrite_snapshot
</span></span></code></pre>
</div>
<p>
You can start server maintenance if:
</p>
<ul>
<li>
<p>
All shards and endpoints have moved to other nodes
</p>
</li>
<li>
<p>
Enough nodes are still online to maintain quorum
</p>
</li>
</ul>
<h3 id="prevent-replica-shard-migration">
Prevent replica shard migration
</h3>
<p>
If you do not have enough resources available to move all of the shards to other nodes, you can turn maintenance mode on without migrating the replica shards.
</p>
<p>
Before you prevent replica shard migration during maintenance mode, consider the following effects:
</p>
<ul>
<li>
<p>
Replica shards remain on the node during maintenance.
</p>
</li>
<li>
<p>
If the maintenance node fails, the master shards do not have replica shards to maintain data redundancy and high availability.
</p>
</li>
<li>
<p>
Replica shards that remain on the node can still be promoted during failover to preserve availability.
</p>
</li>
</ul>
<p>
To activate maintenance mode without replica shard migration, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode on evict_ha_replica disabled evict_active_active_replica disabled
</span></span></code></pre>
</div>
<h3 id="demote-a-master-node">
Demote a master node
</h3>
<p>
If maintenance might affect connectivity to the master node, you can demote the master node when you activate maintenance mode. This lets the cluster elect a new master node.
</p>
<p>
To demote a master node when activating maintenance mode, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode on demote_node
</span></span></code></pre>
</div>
<h3 id="verify-maintenance-mode-activation">
Verify maintenance mode activation
</h3>
<p>
To verify maintenance mode for a node, use
<code>
rladmin status
</code>
and review the node's shards field. If that value is displayed in yellow (shown earlier), then the node is in maintenance mode.
</p>
<p>
Avoid activating maintenance mode when it is already active. Maintenance mode activations stack. If you activate maintenance mode for a node that is already in maintenance mode, you will have to deactivate maintenance mode twice in order to restore full functionality.
</p>
<h2 id="deactivate-maintenance-mode">
Deactivate maintenance mode
</h2>
<p>
When you deactivate maintenance mode, Redis Enterprise:
</p>
<ol>
<li>
<p>
Loads a
<a href="#specify-a-snapshot">
specified node snapshot
</a>
or defaults to the latest maintenance mode snapshot.
</p>
</li>
<li>
<p>
Unmarks the node as a quorum node to allow shards and endpoints to migrate to the node.
</p>
</li>
<li>
<p>
Restores the shards and endpoints that were in the node at the time of the snapshot.
</p>
</li>
<li>
<p>
Deletes the snapshot.
</p>
</li>
</ol>
<p>
To deactivate maintenance mode after server maintenance, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode off
</span></span></code></pre>
</div>
<p>
By default, a snapshot is required to deactivate maintenance mode. If the snapshot cannot be restored, deactivation is cancelled and the node remains in maintenance mode. In such events, it may be necessary to
<a href="#reset_node_status">
reset node status
</a>
.
</p>
<h3 id="specify-a-snapshot">
Specify a snapshot
</h3>
<p>
When you turn off maintenance mode, you can restore the node configuration from a maintenance mode snapshot or any snapshots previously created by
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/snapshot/#node-snapshot-create">
<code>
rladmin node <node_id> snapshot create
</code>
</a>
. If you do not specify a snapshot, Redis Enterprise uses the latest maintenance mode snapshot by default.
</p>
<p>
To get a list of available snapshots, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> snapshot list
</span></span></code></pre>
</div>
<p>
To specify a snapshot when you turn maintenance mode off, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode off snapshot_name <snapshot_name>
</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>
If an error occurs when you turn on maintenance mode, the snapshot is not deleted.
When you rerun the command, use the snapshot from the initial attempt since it contains the original state of the node.
</div>
</div>
<h3 id="skip-shard-restoration">
Skip shard restoration
</h3>
<p>
You can prevent the migrated shards and endpoints from returning to the original node after you turn off maintenance mode.
</p>
<p>
To turn maintenance mode off and skip shard restoration, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode off skip_shards_restore
</span></span></code></pre>
</div>
<h3 id="reset-node-status">
Reset node status
</h3>
<p>
In extreme cases, you may need to reset a node's status. Run the following commands to do so:
</p>
<pre tabindex="0"><code>$ rladmin tune node <node_id> max_listeners 100
$ rladmin tune node <node_id> quorum_only disabled
</code></pre>
<p>
Use these commands with caution. For best results, contact Support before running these commands.
</p>
<h2 id="cluster-status-example">
Cluster status example
</h2>
<p>
This example shows how the output of
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/">
<code>
rladmin status
</code>
</a>
changes when you turn on maintenance mode for a node.
</p>
<p>
The cluster status before turning on maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redislabs@rp1_node1:/opt$ rladmin status
</span></span><span class="line"><span class="cl">CLUSTER NODES:
</span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS
</span></span><span class="line"><span class="cl">*node:1 master 172.17.0.2 rp1_node1 2/100
</span></span><span class="line"><span class="cl">node:2 slave 172.17.0.4 rp3_node1 2/100
</span></span><span class="line"><span class="cl">node:3 slave 172.17.0.3 rp2_node1 0/100
</span></span></code></pre>
</div>
<p>
The cluster status after turning on maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redislabs@rp1_node1:/opt$ rladmin node <span class="m">2</span> maintenance_mode on
</span></span><span class="line"><span class="cl">Performing maintenance_on action on node:2: 0%
</span></span><span class="line"><span class="cl">created snapshot NodeSnapshot<<span class="nv">name</span><span class="o">=</span>maintenance_mode_2019-03-14_09-50-59,time<span class="o">=</span>None,node_uid<span class="o">=</span>2>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">node:2 will not accept any more shards
</span></span><span class="line"><span class="cl">Performing maintenance_on action on node:2: 100%
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redislabs@rp1_node1:/opt$ rladmin status
</span></span><span class="line"><span class="cl">CLUSTER NODES:
</span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS
</span></span><span class="line"><span class="cl">*node:1 master 172.17.0.2 rp1_node1 2/100
</span></span><span class="line"><span class="cl">node:2 slave 172.17.0.4 rp3_node1 0/0
</span></span><span class="line"><span class="cl">node:3 slave 172.17.0.3 rp2_node1 2/100
</span></span></code></pre>
</div>
<p>
After turning on maintenance mode for node 2, Redis Enterprise saves a snapshot of its configuration and then moves its shards and endpoints to node 3.
</p>
<p>
Now node 2 has
<code>
0/0
</code>
shards because shards cannot migrate to it while it is in maintenance mode.
</p>
<h2 id="maintenance-mode-rest-api">
Maintenance mode REST API
</h2>
<p>
You can also turn maintenance mode on or off using
<a href="/docs/latest/operate/rs/references/rest-api/">
REST API requests
</a>
to
<a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/actions/#post-node-action">
<nobr>
POST
<code>
/nodes/{node_uid}/actions/{action}
</code>
</nobr>
</a>
.
</p>
<h3 id="activate-maintenance-mode-rest-api">
Activate maintenance mode (REST API)
</h3>
<p>
Use
<nobr>
<code>
POST /nodes/{node_uid}/actions/maintenance_on
</code>
</nobr>
to activate maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST https://<hostname>:9443/v1/nodes/<node_id>/actions/maintenance_on
</span></span><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"overwrite_snapshot"</span>: true,
</span></span><span class="line"><span class="cl"> <span class="s2">"evict_ha_replica"</span>: true,
</span></span><span class="line"><span class="cl"> <span class="s2">"evict_active_active_replica"</span>: <span class="nb">true</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<p>
You can set
<code>
evict_ha_replica
</code>
and
<code>
evict_active_active_replica
</code>
to
<code>
false
</code>
to
<a href="#prevent-replica-shard-migration">
prevent replica shard migration
</a>
.
</p>
<p>
The
<code>
maintenance_on
</code>
request returns a JSON response body:
</p>
<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">"status"</span><span class="p">:</span><span class="s2">"queued"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"task_id"</span><span class="p">:</span><span class="s2">"<task-id-guid>"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="deactivate-maintenance-mode-rest-api">
Deactivate maintenance mode (REST API)
</h3>
<p>
Use
<nobr>
<code>
POST /nodes/{node_uid}/actions/maintenance_off
</code>
</nobr>
deactivate maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST https://<hostname>:9443/v1/nodes/<node_id>/actions/maintenance_off
</span></span><span class="line"><span class="cl"><span class="o">{</span> <span class="s2">"skip_shards_restore"</span>: <span class="nb">false</span> <span class="o">}</span>
</span></span></code></pre>
</div>
<p>
The
<code>
skip_shards_restore
</code>
boolean flag allows the
<code>
maintenance_off
</code>
action to
<a href="#skip-shard-restoration">
skip shard restoration
</a>
when set to
<code>
true
</code>
.
</p>
<p>
The
<code>
maintenance_off
</code>
request returns a JSON response body:
</p>
<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">"status"</span><span class="p">:</span><span class="s2">"queued"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"task_id"</span><span class="p">:</span><span class="s2">"<task-id-guid>"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="track-action-status">
Track action status
</h3>
<p>
You can send a request to
<a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/actions/#get-node-action">
<nobr>
GET
<code>
/nodes/{node_uid}/actions/{action}
</code>
</nobr>
</a>
to track the
<a href="/docs/latest/operate/rs/references/rest-api/objects/action/">
status
</a>
of the
<code>
maintenance_on
</code>
and
<code>
maintenance_off
</code>
actions.
</p>
<p>
This request returns the status of the
<code>
maintenance_on
</code>
action:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET https://<hostname>:9443/v1/nodes/<node_id>/actions/maintenance_on
</span></span></code></pre>
</div>
<p>
The response body:
</p>
<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">"status"</span><span class="p">:</span><span class="s2">"completed"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"task_id"</span><span class="p">:</span><span class="s2">"38c7405b-26a7-4379-b84c-cab4b3db706d"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</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/rs/clusters/maintenance-mode/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
REST API
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the REST API available to Redis Enterprise Software deployments.
</p>
<p>
Redis Enterprise Software provides a REST API to help you automate common tasks.
</p>
<p>
Here, you'll find the details of the API and how to use it.
</p>
<p>
For more info, see:
</p>
<ul>
<li>
Supported
<a href="/docs/latest/operate/rs/references/rest-api/requests/">
request endpoints
</a>
, organized by path
</li>
<li>
Supported
<a href="/docs/latest/operate/rs/references/rest-api/objects/">
objects
</a>
, both request and response
</li>
<li>
Built-in roles and associated
<a href="/docs/latest/operate/rs/references/rest-api/permissions/">
permissions
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/references/rest-api/quick-start/">
Redis Enterprise Software REST API quick start
</a>
with examples
</li>
</ul>
<h2 id="authentication">
Authentication
</h2>
<p>
Authentication to the Redis Enterprise Software API occurs via
<a href="https://en.wikipedia.org/wiki/Basic_access_authentication">
Basic Auth
</a>
. Provide your username and password as the basic auth credentials.
</p>
<p>
If the username and password is incorrect or missing, the request will fail with a
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized">
<code>
401 Unauthorized
</code>
</a>
status code.
</p>
<p>
Example request using
<a href="https://curl.se/">
cURL
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -u <span class="s2">"[email protected]:password"</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> https://localhost:9443/v1/bdbs
</span></span></code></pre>
</div>
<p>
For more examples, see the
<a href="/docs/latest/operate/rs/references/rest-api/quick-start/">
Redis Enterprise Software REST API quick start
</a>
.
</p>
<h3 id="permissions">
Permissions
</h3>
<p>
By default, the admin user is authorized for access to all endpoints. Use
<a href="/docs/latest/operate/rs/security/access-control/">
role-based access controls
</a>
and
<a href="/docs/latest/operate/rs/references/rest-api/permissions/">
role permissions
</a>
to manage access.
</p>
<p>
If a user attempts to access an endpoint that is not allowed in their role, the request will fail with a
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden">
<code>
403 Forbidden
</code>
</a>
status code. For more details on which user roles can access certain endpoints, see
<a href="/docs/latest/operate/rs/references/rest-api/permissions/">
Permissions
</a>
.
</p>
<h3 id="certificates">
Certificates
</h3>
<p>
The Redis Enterprise Software REST API uses
<a href="/docs/latest/operate/rs/security/certificates/">
Self-signed certificates
</a>
to ensure the product is secure. When you use the default self-signed certificates, the HTTPS requests will fail with
<code>
SSL certificate problem: self signed certificate
</code>
unless you turn off SSL certificate verification.
</p>
<h2 id="ports">
Ports
</h2>
<p>
All calls must be made over SSL to port 9443. For the API to work, port 9443 must be exposed to incoming traffic or mapped to a different port.
</p>
<p>
If you are using a
<a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/docker-quickstart/">
Redis Enterprise Software Docker image
</a>
, run the following command to start the Docker image with port 9443 exposed:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run -p 9443:9443 redislabs/redis
</span></span></code></pre>
</div>
<h2 id="versions">
Versions
</h2>
<p>
All API requests are versioned in order to minimize the impact of backwards-incompatible API changes and to coordinate between different versions operating in parallel.
</p>
<p>
Specify the version in the request
<a href="https://en.wikipedia.org/wiki/Uniform_Resource_Identifier">
URI
</a>
, as shown in the following table:
</p>
<table>
<thead>
<tr>
<th>
Request path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
POST
<code>
/v1/bdbs
</code>
</td>
<td>
A version 1 request for the
<code>
/bdbs
</code>
endpoint.
</td>
</tr>
<tr>
<td>
POST
<code>
/v2/bdbs
</code>
</td>
<td>
A version 2 request for the
<code>
/bdbs
</code>
endpoint.
</td>
</tr>
</tbody>
</table>
<p>
When an endpoint supports multiple versions, each version is documented on the corresponding endpoint. For example, the
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/">
bdbs request
</a>
page documents POST requests for
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/#post-bdbs-v1">
version 1
</a>
and
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/#post-bdbs-v2">
version 2
</a>
.
</p>
<h2 id="headers">
Headers
</h2>
<h3 id="requests">
Requests
</h3>
<p>
Redis Enterprise REST API requests support the following HTTP headers:
</p>
<table>
<thead>
<tr>
<th>
Header
</th>
<th>
Supported/Required Values
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Accept
</td>
<td>
<code>
application/json
</code>
</td>
</tr>
<tr>
<td>
Content-Length
</td>
<td>
Length (in bytes) of request message
</td>
</tr>
<tr>
<td>
Content-Type
</td>
<td>
<code>
application/json
</code>
(required for PUT or POST requests)
</td>
</tr>
</tbody>
</table>
<p>
If the client specifies an invalid header, the request will fail with a
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request">
<code>
400 Bad Request
</code>
</a>
status code.
</p>
<h3 id="responses">
Responses
</h3>
<p>
Redis Enterprise REST API responses support the following HTTP headers:
</p>
<table>
<thead>
<tr>
<th>
Header
</th>
<th>
Supported/Required Values
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Content-Type
</td>
<td>
<code>
application/json
</code>
</td>
</tr>
<tr>
<td>
Content-Length
</td>
<td>
Length (in bytes) of response message
</td>
</tr>
</tbody>
</table>
<h2 id="json-requests-and-responses">
JSON requests and responses
</h2>
<p>
The Redis Enterprise Software REST API uses
<a href="http://www.json.org">
JavaScript Object Notation (JSON)
</a>
for requests and responses. See the
<a href="http://www.ietf.org/rfc/rfc4627.txt">
RFC 4627 technical specifications
</a>
for additional information about JSON.
</p>
<p>
Some responses may have an empty body but indicate the response with standard
<a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">
HTTP codes
</a>
.
</p>
<p>
Both requests and responses may include zero or more objects.
</p>
<p>
If the request is for a single entity, the response returns a single JSON object or none. If the request is for a list of entities, the response returns a JSON array with zero or more elements.
</p>
<p>
If you omit certain JSON object fields from a request, they may be assigned default values, which often indicate that these fields are not in use.
</p>
<h2 id="response-types-and-error-codes">
Response types and error codes
</h2>
<p>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes">
HTTP status codes
</a>
indicate the result of an API request. This can be
<code>
200 OK
</code>
if the server accepted the request, or it can be one of many error codes.
</p>
<p>
The most common responses for a Redis Enterprise API request are:
</p>
<table>
<thead>
<tr>
<th>
Response
</th>
<th>
Condition/Required handling
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">
200 OK
</a>
</td>
<td>
Success
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request">
400 Bad Request
</a>
</td>
<td>
The request failed, generally due to a typo or other mistake.
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized">
401 Unauthorized
</a>
</td>
<td>
The request failed because the authentication information was missing or incorrect.
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden">
403 Forbidden
</a>
</td>
<td>
The user cannot access the specified
<a href="https://en.wikipedia.org/wiki/Uniform_Resource_Identifier">
URI
</a>
.
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found">
404 Not Found
</a>
</td>
<td>
The
<a href="https://en.wikipedia.org/wiki/Uniform_Resource_Identifier">
URI
</a>
does not exist.
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavailable">
503 Service Unavailable
</a>
</td>
<td>
The node is not responding or is not a member of the cluster.
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-505-http-version-not-suppor">
505 HTTP Version Not Supported
</a>
</td>
<td>
An unsupported
<code>
x-api-version
</code>
was used. See
<a href="#versions">
versions
</a>
.
</td>
</tr>
</tbody>
</table>
<p>
Some endpoints return different response codes. The request references for these endpoints document these special cases.
</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/rest-api/"/>
<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/reference/data-transformation-block-types/cassandra_write/.html | <section class="prose w-full py-12 max-w-none">
<h1>
cassandra.write
</h1>
<p class="text-lg -mt-5 mb-10">
Write into a Cassandra data store
</p>
<p>
Write into a Cassandra data store
</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>
connection
</strong>
<br/>
(The connection to use for loading)
</td>
<td>
<code>
string
</code>
</td>
<td>
Logical connection name as defined in the connections.yaml
<br/>
</td>
<td>
yes
</td>
</tr>
<tr>
<td>
<strong>
keyspace
</strong>
</td>
<td>
<code>
string
</code>
</td>
<td>
Keyspace
<br/>
</td>
<td>
yes
</td>
</tr>
<tr>
<td>
<strong>
table
</strong>
<br/>
(The target table name)
</td>
<td>
<code>
string
</code>
</td>
<td>
Target table name
<br/>
</td>
<td>
yes
</td>
</tr>
<tr>
<td>
<a href="#keys">
<strong>
keys
</strong>
</a>
<br/>
(Business keys)
</td>
<td>
<code>
array
</code>
</td>
<td>
</td>
<td>
yes
</td>
</tr>
<tr>
<td>
<a href="#mapping">
<strong>
mapping
</strong>
</a>
<br/>
(Fields to write)
</td>
<td>
<code>
array
</code>
</td>
<td>
</td>
<td>
yes
</td>
</tr>
<tr>
<td>
<strong>
opcode_field
</strong>
</td>
<td>
<code>
string
</code>
</td>
<td>
Name of the field in the payload that holds the operation (c - create, d - delete, u - update) for this record in the DB
<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">id</span><span class="p">:</span><span class="w"> </span><span class="l">load_snowflake</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l">relational.write</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">properties</span><span class="p">:</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">eu_datalake</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">employees</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">load_strategy</span><span class="p">:</span><span class="w"> </span><span class="l">APPEND</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
<a name="keys">
</a>
</p>
<h2 id="keys-business-keys">
keys[]: Business keys
</h2>
<p>
<strong>
Items: name of column
</strong>
</p>
<p>
<strong>
No properties.
</strong>
</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="l">fname</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span>- <span class="nt">lname</span><span class="p">:</span><span class="w"> </span><span class="l">last_name</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
<a name="mapping">
</a>
</p>
<h2 id="mapping-fields-to-write">
mapping[]: Fields to write
</h2>
<p>
<strong>
Items: name of column
</strong>
</p>
<p>
<strong>
No properties.
</strong>
</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="l">fname</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span>- <span class="nt">lname</span><span class="p">:</span><span class="w"> </span><span class="l">last_name</span><span class="w">
</span></span></span><span class="line"><span class="cl"><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="l">gender</span><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/write-behind/reference/data-transformation-block-types/cassandra_write/"/>
<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/timeseries/config/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Time series configuration compatibility with Redis Enterprise
</h1>
<p class="text-lg -mt-5 mb-10">
Time series configuration settings supported by Redis Enterprise Software and Redis Cloud.
</p>
<h2 id="configure-time-series-in-redis-software">
Configure time series in Redis Software
</h2>
<p>
<a href="/docs/latest/operate/rs/">
Redis Enterprise Software
</a>
lets you manually change any
<a href="/docs/latest/develop/data-types/timeseries/configuration/#redistimeseries-configuration-parameters">
RedisTimeSeries configuration setting
</a>
.
</p>
<p>
To change RedisTimeSeries configuration using the Redis Software Cluster Manager UI:
</p>
<ol>
<li>
<p>
From the
<strong>
Databases
</strong>
list, select the database, then click
<strong>
Configuration
</strong>
.
</p>
</li>
<li>
<p>
Select the
<strong>
Edit
</strong>
button.
</p>
</li>
<li>
<p>
In the
<strong>
Capabilities
</strong>
section, click
<strong>
Parameters
</strong>
.
</p>
</li>
<li>
<p>
After you finish editing the module's configuration parameters, click
<strong>
Done
</strong>
to close the parameter editor.
</p>
</li>
<li>
<p>
Click
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<h2 id="configure-time-series-in-redis-cloud">
Configure time series in Redis Cloud
</h2>
<p>
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
does not let you configure RedisTimeSeries manually. However, if you have a Flexible or Annual
<a href="/docs/latest/operate/rc/subscriptions/">
subscription
</a>
, you can contact
<a href="https://redis.com/company/support/">
support
</a>
to request a configuration change. You cannot change RedisTimeSeries configuration for Free or Fixed subscriptions.
</p>
<h2 id="configuration-settings">
Configuration settings
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
Setting
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
Notes
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/timeseries/configuration/">
CHUNK_SIZE_BYTES
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default:
<code>
4096
</code>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/timeseries/configuration/">
COMPACTION_POLICY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: No default compaction rules
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/timeseries/configuration/">
DUPLICATE_POLICY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default:
<code>
BLOCK
</code>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/timeseries/configuration/">
ENCODING
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default:
<code>
COMPRESSED
</code>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/timeseries/configuration/">
NUM_THREADS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual*
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
* Updates automatically when you change your plan.
<br/>
<br/>
Redis Enterprise default: Set by plan
<br/>
<br/>
Redis Cloud defaults:
<br/>
• Flexible & Annual: Set by plan
<br/>
• Free & Fixed:
<code>
1
</code>
<br/>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/timeseries/configuration/">
RETENTION_POLICY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default:
<code>
0
</code>
</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/timeseries/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/develop/data-types/timeseries/clients/.html | <section class="prose w-full py-12">
<h1>
Clients
</h1>
<p class="text-lg -mt-5 mb-10">
Time Series Client Libraries
</p>
<p>
The table below shows the client libraries that support Redis time series:
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
Language
</th>
<th style="text-align:left">
Client
</th>
</tr>
</thead>
<tbody>
<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>
<tr>
<td style="text-align:left">
JavaScript
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/clients/nodejs/">
node-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>
</td>
</tr>
<tr>
<td style="text-align:left">
C#/.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="https://github.com/RedisTimeSeries/redistimeseries-go/">
redistimeseries-go
</a>
</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/develop/data-types/timeseries/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/script-load/.html | <section class="prose w-full py-12">
<h1 class="command-name">
SCRIPT LOAD
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">SCRIPT LOAD script</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.6.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) with N being the length in bytes of the script body.
</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>
@scripting
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Load a script into the scripts cache, without executing it.
After the specified command is loaded into the script cache it will be callable
using
<a href="/docs/latest/commands/evalsha/">
<code>
EVALSHA
</code>
</a>
with the correct SHA1 digest of the script, exactly like after
the first successful invocation of
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
.
</p>
<p>
The script is guaranteed to stay in the script cache forever (unless
<code>
SCRIPT FLUSH
</code>
is called).
</p>
<p>
The command works in the same way even if the script was already present in the
script cache.
</p>
<p>
For more information about
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
scripts please refer to
<a href="/docs/latest/develop/interact/programmability/eval-intro/">
Introduction to Eval Scripts
</a>
.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the SHA1 digest of the script added into the script cache.
<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/script-load/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Security
</h1>
<p>
Redis Cloud provides a number of ways to secure subscriptions and databases.
</p>
<p>
As a Redis Cloud user, consider these security domains:
</p>
<ul>
<li>
The
<a href="#admin-console-security">
Redis Cloud console
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/database-security/">
Your databases
</a>
</li>
<li>
The
<a href="/docs/latest/operate/rc/api/get-started/enable-the-api/">
Redis Cloud API
</a>
</li>
</ul>
<p>
First, you might want to review our
<a href="/docs/latest/operate/rc/security/shared-responsibility-model/">
shared responsibility model
</a>
for security.
</p>
<h2 id="admin-console-security">
Redis Cloud console security
</h2>
<p>
The Redis Cloud console is the web application you use to manage your Redis Cloud deployments.
</p>
<p>
Secure access to the Redis Cloud console by:
</p>
<ul>
<li>
<p>
Assigning appropriate roles to
<a href="/docs/latest/operate/rc/security/access-control/access-management/#team-management-roles">
team members with access
</a>
.
</p>
</li>
<li>
<p>
Enabling
<a href="/docs/latest/operate/rc/security/access-control/multi-factor-authentication/">
multi-factor authentication
</a>
.
</p>
</li>
<li>
<p>
Enabling
<a href="/docs/latest/operate/rc/security/access-control/saml-sso/">
SAML SSO
</a>
.
</p>
</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>
A user session on Redis Cloud expires after 30 minutes. You'll be signed out of Redis Cloud after 30 minutes of inactivity.
</div>
</div>
<h2 id="database-security">
Database security
</h2>
<p>
You have several options when it comes to securing your Redis Cloud databases. For more information, see
<a href="/docs/latest/operate/rc/security/database-security/">
Cloud database security
</a>
. Options include:
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/security/encryption-at-rest/">
Encryption at rest
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/">
Role-based access control
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/database-security/tls-ssl/">
TLS
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/database-security/network-security/">
Network security
</a>
using
<a href="/docs/latest/operate/rc/security/vpc-peering/">
VPC peering
</a>
and
<a href="/docs/latest/operate/rc/security/cidr-whitelist/">
CIDR whitelist
</a>
</li>
</ul>
<h2 id="api-security">
API security
</h2>
<p>
The Redis Cloud API allows you to programmatically administer your subscriptions and database deployments. This API is disabled by default. When you
<a href="/docs/latest/operate/rc/api/get-started/enable-the-api/">
enable the API
</a>
, you can then
<a href="/docs/latest/operate/rc/api/get-started/manage-api-keys/">
manage the API keys
</a>
for all owners of your Redis Cloud account. For an overview of the security features of the API, see the
<a href="/docs/latest/operate/rc/api/get-started/">
API authentication documentation
</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/"/>
<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/redisvl/api/.html | <section class="prose w-full py-12 max-w-none">
<h1>
API Guide
</h1>
<p class="text-lg -mt-5 mb-10">
The RedisVL API guide
</p>
<nav>
<a href="/docs/latest/integrate/redisvl/api/schema/">
Schema
</a>
<p>
The schema APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/query/">
Query
</a>
<p>
The query APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/searchindex/">
Search index
</a>
<p>
The search index APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/filter/">
Filter
</a>
<p>
The filter APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/vectorizer/">
Vectorizers
</a>
<p>
The vectorizer APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/cache/">
LLMCache
</a>
<p>
The LLMCache APIs
</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/redisvl/api/"/>
<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/install/install-redis/install-redis-on-windows/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Install Redis on Windows
</h1>
<p class="text-lg -mt-5 mb-10">
Use Redis on Windows for development
</p>
<p>
Redis is not officially supported on Windows. However, you can install Redis on Windows for development by following the instructions below.
</p>
<p>
To install Redis on Windows, you'll first need to enable
<a href="https://docs.microsoft.com/en-us/windows/wsl/install">
WSL2
</a>
(Windows Subsystem for Linux). WSL2 lets you run Linux binaries natively on Windows. For this method to work, you'll need to be running Windows 10 version 2004 and higher or Windows 11.
</p>
<h2 id="install-or-enable-wsl2">
Install or enable WSL2
</h2>
<p>
Microsoft provides
<a href="https://docs.microsoft.com/en-us/windows/wsl/install">
detailed instructions for installing WSL
</a>
. Follow these instructions, and take note of the default Linux distribution it installs. This guide assumes Ubuntu.
</p>
<h2 id="install-redis">
Install Redis
</h2>
<p>
Once you're running Ubuntu on Windows, you can follow the steps detailed at
<a href="/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-linux/#install-on-ubuntu-debian">
Install on Ubuntu/Debian
</a>
to install recent stable versions of Redis from the official
<code>
packages.redis.io
</code>
APT repository.
Add the repository to the
<code>
apt
</code>
index, update it, and then install:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -fsSL https://packages.redis.io/gpg <span class="p">|</span> sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s2">"deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb </span><span class="k">$(</span>lsb_release -cs<span class="k">)</span><span class="s2"> main"</span> <span class="p">|</span> sudo tee /etc/apt/sources.list.d/redis.list
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">sudo apt-get update
</span></span><span class="line"><span class="cl">sudo apt-get install redis</span></span></code></pre>
</div>
<p>
Lastly, start the Redis server like so:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo service redis-server start</span></span></code></pre>
</div>
<h2 id="connect-to-redis">
Connect to Redis
</h2>
<p>
Once Redis is running, you can test it by running
<code>
redis-cli
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis-cli</span></span></code></pre>
</div>
<p>
Test the connection with the
<code>
ping
</code>
command:
</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> ping
</span></span><span class="line"><span class="cl">PONG</span></span></code></pre>
</div>
<p>
You can also test that your Redis server is running using
<a href="/docs/latest/develop/tools/insight/">
Redis Insight
</a>
.
</p>
<h2 id="next-steps">
Next steps
</h2>
<p>
Once you have a running Redis instance, you may want to:
</p>
<ul>
<li>
Try the
<a href="/docs/latest/develop/tools/cli/">
Redis CLI tutorial
</a>
</li>
<li>
Connect using one of the
<a href="/docs/latest/develop/clients/">
Redis clients
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/install/install-redis/#install-redis-properly">
Install Redis "properly"
</a>
for production use.
</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/install/install-redis/install-redis-on-windows/"/>
<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/redisgraph/redisgraph-1.0-release-notes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
RedisGraph 1.0 release notes
</h1>
<p class="text-lg -mt-5 mb-10">
Fixed memory leaks. Support ‘*’ within RETURN clause. Added TYPE function. Initial support for UNWIND clause.
</p>
<h2 id="requirements">
Requirements
</h2>
<p>
RedisGraph v1.0.15 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="v1015-march-2019">
v1.0.15 (March 2019)
</h2>
<ul>
<li>
GraphBLAS 2.3.0
<a href="https://github.com/RedisLabsModules/RedisGraph/pull/390#issuecomment-470620353">
release notes
</a>
</li>
<li>
WITH clause: Allows query parts to be chained together, piping the results from one to be used as starting points or criteria of the next.
<a href="https://s3.amazonaws.com/artifacts.opencypher.org/openCypher9.pdf">
ref p.78
</a>
</li>
<li>
Enhancements
<ul>
<li>
#
<a href="https://github.com/RedisGraph/RedisGraph/issues/393">
393
</a>
Discard distinct when performing aggregation
</li>
</ul>
</li>
<li>
Minor bugfixes
<ul>
<li>
#
<a href="https://github.com/RedisGraph/RedisGraph/issues/359">
359
</a>
Adding ORDER BY changes the number of returned hits when used in combination with LIMIT
</li>
<li>
#
<a href="https://github.com/RedisGraph/RedisGraph/issues/363">
363
</a>
Remove graph entity property when it is set to null
</li>
<li>
#
<a href="https://github.com/RedisGraph/RedisGraph/issues/386">
386
</a>
Return updated values on queries that modify data
</li>
</ul>
</li>
</ul>
<h2 id="v1014-21-february-2019">
v1.0.14 (21 February 2019)
</h2>
<p>
License update, REDIS SOURCE AVAILABLE LICENSE AGREEMENT.
</p>
<h2 id="v1013-6-february-2019">
v1.0.13 (6 February 2019)
</h2>
<p>
Reuse attribute name to avoid duplication
</p>
<h2 id="v1012-28-january-2019">
v1.0.12 (28 January 2019)
</h2>
<p>
Traverse direction optimization to reduce number of matrix transpose
</p>
<h2 id="v1011-17-january-2019">
v1.0.11 (17 January 2019)
</h2>
<ul>
<li>
Removed OpenMP requirement
</li>
<li>
Traverse from multiple nodes concurrently
</li>
</ul>
<h2 id="v1010-9-january-2019">
v1.0.10 (9 January 2019)
</h2>
<p>
Update indices when MERGE creates new entities
</p>
<h2 id="v109-6-january-2019">
v1.0.9 (6 January 2019)
</h2>
<ul>
<li>
Support for mixing MERGE and SET clauses
</li>
<li>
Granular writer locking
</li>
<li>
Fix graph serialization error in duplicate edge handling
</li>
</ul>
<h2 id="v108-24-december-2018">
v1.0.8 (24 December 2018)
</h2>
<ul>
<li>
Index utilization when performing cartesian product
</li>
<li>
Increase usage of rm_malloc functions in module
</li>
<li>
Allow serialization of NULL-valued properties
</li>
<li>
Support for multiple relationship types
</li>
</ul>
<h2 id="v107-18-december-2018">
v1.0.7 (18 December 2018)
</h2>
<ul>
<li>
Bulk-insert support unicode
</li>
<li>
Bulk-insert better progress reporting
</li>
<li>
Multiple relationship types
</li>
</ul>
<h2 id="v105-15-december-2018">
v1.0.5 (15 December 2018)
</h2>
<p>
Bulk insert supports ID specifying + relationships attributes
</p>
<h2 id="v104-9-december-2018">
v1.0.4 (9 December 2018)
</h2>
<ul>
<li>
Compact GraphBLAS, using structural semiring
</li>
</ul>
<h2 id="v103-2-december-2018">
v1.0.3 (2 December 2018)
</h2>
<ul>
<li>
GraphBLAS 2.2
</li>
<li>
Multiple CREATE clauses
</li>
<li>
Multiple MATCH clauses
</li>
<li>
Bug fixes:
<ul>
<li>
Replace operations appropriately when rewriting execution plan
</li>
<li>
Entity returned from datablock should have its internals cleared
</li>
<li>
Loaded triemap strings are not guaranteed space for a null terminator
</li>
</ul>
</li>
</ul>
<h2 id="v102-25-november-2018">
v1.0.2 (25 November 2018)
</h2>
<ul>
<li>
Bug fix #
<a href="https://github.com/RedisGraph/RedisGraph/issues/249">
249
</a>
reset operation within execution plan should propagate upwards
</li>
</ul>
<h2 id="v101-22-november-2018">
v1.0.1 (22 November 2018)
</h2>
<ul>
<li>
Resolved a number of memory leaks
</li>
<li>
Support '*' within RETURN clause
</li>
<li>
Add TYPE function
</li>
<li>
Initial support for UNWIND clause
</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/redisgraph/redisgraph-1.0-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/rs/7.4/references/rest-api/requests/nodes/stats/last/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Latest node stats requests
</h1>
<p class="text-lg -mt-5 mb-10">
Most recent node statistics requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-nodes-stats-last">
GET
</a>
</td>
<td>
<code>
/v1/nodes/stats/last
</code>
</td>
<td>
Get latest stats for all nodes
</td>
</tr>
<tr>
<td>
<a href="#get-node-stats-last">
GET
</a>
</td>
<td>
<code>
/v1/nodes/stats/last/{uid}
</code>
</td>
<td>
Get latest stats for a single node
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-nodes-stats-last">
Get latest stats for all nodes
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/nodes/stats/last
</span></span></code></pre>
</div>
<p>
Get latest statistics for all nodes.
</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_all_nodes_stats">
view_all_nodes_stats
</a>
</td>
</tr>
</tbody>
</table>
<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 /nodes/stats/last?interval<span class="o">=</span>1sec<span class="p">&</span><span class="nv">stime</span><span class="o">=</span>2015-10-14T06:29:43Z
</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="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. Default: 1sec. (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-all-response">
Response
</h3>
<p>
Returns most recent
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for all nodes.
</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">"1"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"conns"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_idle"</span><span class="p">:</span> <span class="mf">0.922500000015134</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_system"</span><span class="p">:</span> <span class="mf">0.007499999999708962</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_user"</span><span class="p">:</span> <span class="mf">0.01749999999810825</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cur_aof_rewrites"</span><span class="p">:</span> <span class="mf">0.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="mf">7887.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_avail"</span><span class="p">:</span> <span class="mf">75821363200.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_free"</span><span class="p">:</span> <span class="mf">81189969920.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">"2015-10-14T06:29:44Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"free_memory"</span><span class="p">:</span> <span class="mf">2956963840.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="mf">4950.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">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_avail"</span><span class="p">:</span> <span class="mf">75821363200.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_free"</span><span class="p">:</span> <span class="mf">81189969920.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">"2015-10-14T06:29:43Z"</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="mf">0.0</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"2"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"conns"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_idle"</span><span class="p">:</span> <span class="mf">0.922500000015134</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><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-all-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.5">
404 Not Found
</a>
</td>
<td>
No nodes exist
</td>
</tr>
</tbody>
</table>
<h2 id="get-node-stats-last">
Get latest node stats
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/nodes/stats/last/<span class="o">{</span>int: uid<span class="o">}</span>
</span></span></code></pre>
</div>
<p>
Get the latest statistics of a node.
</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/#view_node_stats">
view_node_stats
</a>
</td>
</tr>
</tbody>
</table>
<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 /nodes/stats/last/1?interval<span class="o">=</span>1sec<span class="p">&</span><span class="nv">stime</span><span class="o">=</span>2015-10-13T09:01:54Z
</span></span></code></pre>
</div>
<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>
uid
</td>
<td>
integer
</td>
<td>
The unique ID of the node requested.
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters-1">
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. Default: 1sec. (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>
Returns the most recent
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for the specified node.
</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">"1"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"conns"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_idle"</span><span class="p">:</span> <span class="mf">0.8049999999930151</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_system"</span><span class="p">:</span> <span class="mf">0.02750000000014552</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_user"</span><span class="p">:</span> <span class="mf">0.12000000000080036</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cur_aof_rewrites"</span><span class="p">:</span> <span class="mf">0.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="mf">2169.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_avail"</span><span class="p">:</span> <span class="mf">75920293888.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_free"</span><span class="p">:</span> <span class="mf">81288900608.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">"2015-10-13T09:01:55Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"free_memory"</span><span class="p">:</span> <span class="mf">3285381120.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="mf">3020.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">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_avail"</span><span class="p">:</span> <span class="mf">75920293888.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_free"</span><span class="p">:</span> <span class="mf">81288900608.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">"2015-10-13T09:01:54Z"</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="mf">0.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></code></pre>
</div>
<h3 id="get-error-codes">
Error 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.5">
404 Not Found
</a>
</td>
<td>
Node does not exist
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7">
406 Not Acceptable
</a>
</td>
<td>
Node isn't currently active
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4">
503 Service Unavailable
</a>
</td>
<td>
Mode is in recovery state
</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/nodes/stats/last/"/>
<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/users/authorize/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Authorize user requests
</h1>
<p class="text-lg -mt-5 mb-10">
Users authorization requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#post-authorize">
POST
</a>
</td>
<td>
<code>
/v1/users/authorize
</code>
</td>
<td>
Authorize a user
</td>
</tr>
</tbody>
</table>
<h2 id="post-authorize">
Authorize user
</h2>
<pre><code>POST /v1/users/authorize
</code></pre>
<p>
Generate a JSON Web Token (JWT) for a user to use as authorization to access the REST API.
</p>
<h3 id="post-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>POST /users/authorize
</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">"username"</span><span class="p">:</span> <span class="s2">"[email protected]"</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">"my_password"</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>
<p>
Include a
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/jwt_authorize/">
JWT authorize object
</a>
with a valid username and password in the request body.
</p>
<h3 id="post-response">
Response
</h3>
<p>
Returns a JSON object that contains the generated access token.
</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">"access_token"</span><span class="p">:</span> <span class="s2">"eyJ5bGciOiKIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXViOjE0NjU0NzU0ODYsInVpZFI1IjEiLCJleHAiOjE0NjU0Nz30OTZ9.2xYXumd1rDoE0edFzcLElMOHsshaqQk2HUNgdsUKxMU"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<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>
fields 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>
password_expired
</td>
<td>
The password has expired and must be changed.
</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>
The user is authorized.
</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 could not be understood by the server due to malformed syntax.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">
401 Unauthorized
</a>
</td>
<td>
The user is unauthorized.
</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/users/authorize/"/>
<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/server/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Server management commands compatibility
</h1>
<p class="text-lg -mt-5 mb-10">
Server management commands compatibility.
</p>
<p>
The following tables show which Redis Community Edition
<a href="/docs/latest/commands/?group=server">
server management commands
</a>
are compatible with standard and Active-Active databases in Redis Enterprise Software and Redis Cloud.
</p>
<h2 id="access-control-commands">
Access control commands
</h2>
<p>
Several access control list (ACL) commands are not available in Redis Enterprise. Instead, you can manage access controls from the
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
Redis Enterprise Software Cluster Manager UI
</a>
and the
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/">
Redis Cloud console
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-cat/">
ACL CAT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-deluser/">
ACL DELUSER
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-dryrun/">
ACL DRYRUN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Might reply with "unknown user" for LDAP users even if
<code>
AUTH
</code>
succeeds.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-genpass/">
ACL GENPASS
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-getuser/">
ACL GETUSER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-help/">
ACL HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-list/">
ACL LIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-load/">
ACL LOAD
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-log/">
ACL LOG
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-save/">
ACL SAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-setuser/">
ACL SETUSER
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-users/">
ACL USERS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-whoami/">
ACL WHOAMI
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
</tbody>
</table>
<h2 id="configuration-commands">
Configuration commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-get/">
CONFIG GET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/compatibility/config-settings/">
Only supports a subset of configuration settings.
</a>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-resetstat/">
CONFIG RESETSTAT
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-rewrite/">
CONFIG REWRITE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-set/">
CONFIG SET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/compatibility/config-settings/">
Only supports a subset of configuration settings.
</a>
</td>
</tr>
</tbody>
</table>
<h2 id="general-server-commands">
General server commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command/">
COMMAND
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-count/">
COMMAND COUNT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-docs/">
COMMAND DOCS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-getkeys/">
COMMAND GETKEYS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-getkeysandflags/">
COMMAND GETKEYSANDFLAGS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-help/">
COMMAND HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-info/">
COMMAND INFO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-list/">
COMMAND LIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/debug/">
DEBUG
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/flushall/">
FLUSHALL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active*
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
*Can use the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/flush/">
Active-Active flush API request
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/flushdb/">
FLUSHDB
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active*
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
*Can use the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/crdbs/flush/">
Active-Active flush API request
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lolwut/">
LOLWUT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/shutdown/">
SHUTDOWN
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/swapdb/">
SWAPDB
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/time/">
TIME
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="module-commands">
Module commands
</h2>
<p>
For Redis Enterprise Software, you can
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/">
manage Redis modules
</a>
from the Cluster Manager UI or with
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/modules/">
REST API requests
</a>
.
</p>
<p>
Redis Cloud manages modules for you and lets you
<a href="/docs/latest/operate/rc/databases/create-database/#modules">
enable modules
</a>
when you create a database.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-help/">
MODULE HELP
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-list/">
MODULE LIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-load/">
MODULE LOAD
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-loadex/">
MODULE LOADEX
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-unload/">
MODULE UNLOAD
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="monitoring-commands">
Monitoring commands
</h2>
<p>
Although Redis Enterprise does not support certain monitoring commands, you can use the Cluster Manager UI to view Redis Enterprise Software
<a href="/docs/latest/operate/rs/7.4/clusters/monitoring/">
metrics
</a>
and
<a href="/docs/latest/operate/rs/7.4/clusters/logging/">
logs
</a>
or the Redis Cloud console to view Redis Cloud
<a href="/docs/latest/operate/rc/databases/monitor-performance/">
metrics
</a>
and
<a href="/docs/latest/operate/rc/logs-reports/system-logs/">
logs
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/dbsize/">
DBSIZE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/info/">
INFO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
In Redis Enterprise,
<code>
INFO
</code>
returns a different set of fields than Redis Community Edition.
<br/>
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-doctor/">
LATENCY DOCTOR
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-graph/">
LATENCY GRAPH
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-help/">
LATENCY HELP
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-histogram/">
LATENCY HISTOGRAM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-history/">
LATENCY HISTORY
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-latest/">
LATENCY LATEST
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-reset/">
LATENCY RESET
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-doctor/">
MEMORY DOCTOR
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-help/">
MEMORY HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
in Redis versions earlier than 7.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-malloc-stats/">
MEMORY MALLOC-STATS
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-purge/">
MEMORY PURGE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-stats/">
MEMORY STATS
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-usage/">
MEMORY USAGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
in Redis versions earlier than 7.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/monitor/">
MONITOR
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slowlog-get/">
SLOWLOG GET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slowlog-len/">
SLOWLOG LEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slowlog-reset/">
SLOWLOG RESET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
</tbody>
</table>
<h2 id="persistence-commands">
Persistence commands
</h2>
<p>
Data persistence and backup commands are not available in Redis Enterprise. Instead, you can
<a href="/docs/latest/operate/rs/7.4/databases/configure/database-persistence/">
manage data persistence
</a>
and
<a href="/docs/latest/operate/rs/7.4/databases/import-export/schedule-backups/">
backups
</a>
from the Redis Enterprise Software Cluster Manager UI and the
<a href="/docs/latest/operate/rc/databases/view-edit-database/#durability-section">
Redis Cloud console
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bgrewriteaof/">
BGREWRITEAOF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bgsave/">
BGSAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lastsave/">
LASTSAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/save/">
SAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="replication-commands">
Replication commands
</h2>
<p>
Redis Enterprise automatically manages
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/replication/">
replication
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/failover/">
FAILOVER
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/migrate/">
MIGRATE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/psync/">
PSYNC
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/replconf/">
REPLCONF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/replicaof/">
REPLICAOF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/restore-asking/">
RESTORE-ASKING
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/role/">
ROLE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slaveof/">
SLAVEOF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v5.0.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sync/">
SYNC
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</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/references/compatibility/commands/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/integrate/terraform-provider-for-redis-cloud/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Terraform provider for Redis Cloud
</h1>
<p>
<a href="https://developer.hashicorp.com/terraform">
Terraform
</a>
is an open source automation tool developed by Hashicorp that allows you to easily provision infrastructure as code.
</p>
<p>
Redis develops and maintains a
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest">
Terraform provider for Redis Cloud
</a>
. The Redis Cloud Terraform provider allows many of the same actions as found in the
<a href="/docs/latest/operate/rc/api/">
Redis Cloud API
</a>
.
</p>
<p>
See
<a href="/docs/latest/integrate/terraform-provider-for-redis-cloud/get-started/">
Get started with Terraform
</a>
for an example of how to use the Terraform provider.
</p>
<h2 id="data-sources-and-resources">
Data sources and Resources
</h2>
<p>
The Terraform provider represents API actions as data sources and resources. Data sources are read-only and allow you to get information, while resources allow you to create and manage infrastructure.
</p>
<p>
The Redis Cloud Terraform provider allows for the following data sources:
</p>
<ul>
<li>
Redis Cloud Pro:
<ul>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_subscription">
Subscriptions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_database">
Databases
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_database_modules">
Database capabilities
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_subscription_peerings">
VPC peering connections
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_cloud_account">
Cloud accounts
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_data_persistence">
Supported persistence options
</a>
</li>
</ul>
</li>
<li>
Redis Cloud Essentials:
<ul>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_essentials_plan">
Plans
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_essentials_subscription">
Subscriptions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_essentials_database">
Databases
</a>
</li>
</ul>
</li>
<li>
Active-Active:
<ul>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_active_active_subscription">
Subscriptions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_active_active_subscription_database">
Databases
</a>
</li>
</ul>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_payment_method">
Payment methods
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_regions">
Supported cloud provider regions
</a>
</li>
<li>
ACL
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_acl_role">
roles
</a>
,
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_acl_rule">
rules
</a>
, and
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_acl_user">
users
</a>
</li>
</ul>
<p>
It also allows you to create and manage the following resources:
</p>
<ul>
<li>
Redis Cloud Pro:
<ul>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_subscription">
Subscriptions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_subscription_database">
Databases
</a>
<ul>
<li>
<strong>
NOTE
</strong>
: Upgrade your Terraform provider to version 1.8.1 to create databases with Search and Query.
</li>
</ul>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_subscription_peering">
VPC peering connections
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_cloud_account">
Cloud accounts
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_transit_gateway_attachment">
Transit Gateway attachments
</a>
</li>
</ul>
</li>
<li>
Redis Cloud Essentials:
<ul>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_essentials_subscription">
Subscriptions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_essentials_database">
Databases
</a>
</li>
</ul>
</li>
<li>
Active-Active:
<ul>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_active_active_subscription">
Subscriptions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_active_active_subscription_database">
Databases
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_active_active_subscription_regions">
Regions
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_active_active_subscription_peering">
VPC peering connections
</a>
</li>
</ul>
</li>
<li>
ACL
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_acl_rule">
rules
</a>
,
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_acl_role">
roles
</a>
, and
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_acl_user">
users
</a>
</li>
</ul>
<h2 id="more-info">
More info
</h2>
<ul>
<li>
<a href="/docs/latest/integrate/terraform-provider-for-redis-cloud/get-started/">
Get started with Terraform
</a>
</li>
<li>
<a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs">
Redis Cloud Terraform Registry
</a>
</li>
<li>
<a href="https://developer.hashicorp.com/terraform/docs">
Terraform documentation
</a>
</li>
<li>
<a href="https://developer.hashicorp.com/terraform/language/syntax/configuration">
Terraform configuration syntax
</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/integrate/terraform-provider-for-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/clusters/logging/rsyslog-logging/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rsyslog logging
</h1>
<p class="text-lg -mt-5 mb-10">
This document explains the structure of Redis Enterprise Software log entries in
<code>
rsyslog
</code>
and how to use these log entries to identify events.
</p>
<h2 id="log-concepts">
Log concepts
</h2>
<p>
Redis Enterprise Software logs information from a variety of components in response to actions and events that occur within the cluster.
</p>
<p>
In some cases, a single action, such as removing a node from the cluster, may actually consist of several events. These actions may generate multiple log entries.
</p>
<p>
All log entries displayed in the Cluster Manager UI are also written to
<code>
syslog
</code>
. You can configure
<code>
rsyslog
</code>
to monitor
<code>
syslog
</code>
. Enabled alerts are logged to
<code>
syslog
</code>
and appear with other log entries.
</p>
<p>
You can also
<a href="/docs/latest/operate/rs/7.4/clusters/logging/log-security/">
manage your logs
</a>
with a remote logging server and log rotation.
</p>
<h3 id="types-of-log-entries">
Types of log entries
</h3>
<p>
Log entries are categorized into events and alerts. Both types of entries appear in the logs, but alert log entries also include a boolean
<code>
"state"
</code>
parameter that indicates whether the alert is enabled or disabled.
</p>
<p>
Log entries include information about the specific event that occurred. See the log entry tables for
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
alerts and events
</a>
for more details.
</p>
<h3 id="severity">
Severity
</h3>
<p>
You can also configure
<code>
rsyslog
</code>
to add other information, such as the event severity.
</p>
<p>
Since
<code>
rsyslog
</code>
entries do not include severity by default, you can follow these steps to enable it:
</p>
<ol>
<li>
<p>
Add the following line to
<code>
/etc/rsyslog.conf
</code>
:
</p>
<pre tabindex="0"><code>$template TraditionalFormatWithPRI,"%pri-text%: %timegenerated% %HOSTNAME% %syslogtag%%msg:::drop-last-lf%\n"
</code></pre>
</li>
<li>
<p>
Modify
<code>
$ActionFileDefaultTemplate
</code>
to use your new template
<code>
$ActionFileDefaultTemplateTraditionalFormatWithPRI
</code>
</p>
</li>
<li>
<p>
Save these changes and restart
<code>
rsyslog
</code>
to apply them
</p>
</li>
</ol>
<p>
You can see the log entries for alerts and events in the
<code>
/var/log/messages
</code>
file.
</p>
<p>
<strong>
Command components:
</strong>
</p>
<ul>
<li>
<code>
%pritext%
</code>
adds the severity
</li>
<li>
<code>
%timegenerated%
</code>
adds the timestamp
</li>
<li>
<code>
%HOSTNAME%
</code>
adds the machine name
</li>
<li>
<code>
%syslogtag%
</code>
adds the Redis Enterprise Software message. See the
<a href="#log-entry-structure">
log entry structure
</a>
section for more details.
</li>
<li>
<code>
%msg:::droplastlf%n
</code>
removes duplicated log entries
</li>
</ul>
<h2 id="log-entry-structure">
Log entry structure
</h2>
<p>
The log entries have the following basic structure:
</p>
<pre><code>event_log[<process id>]:{<list of key-value pairs in any order>}
</code></pre>
<ul>
<li>
<strong>
event_log
</strong>
: Plain static text is always shown at the beginning of the entry.
</li>
<li>
<strong>
process id
</strong>
: The ID of the logging process
</li>
<li>
<strong>
list of key-value pairs in any order
</strong>
: A list of key-value pairs that describe the specific event. They can appear in any order. Some key-value pairs are always shown, and some appear depending on the specific event.
<ul>
<li>
<strong>
Key-value pairs that always appear:
</strong>
<ul>
<li>
<code>
"type"
</code>
: A unique code name for the logged event. For the list of codenames, see the
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
tables.
</li>
<li>
<code>
"object"
</code>
: Defines the object type and ID (if relevant) of the object this event relates to, such as cluster, node with ID, BDB with ID, etc. Has the format of
<nobr>
<code>
<object type>[:<id>]
</code>
</nobr>
.
</li>
<li>
<code>
"time"
</code>
: Unix epoch time but can be ignored in this context.
</li>
</ul>
</li>
<li>
<strong>
Key-value pairs that might appear depending on the specific entry:
</strong>
<ul>
<li>
<code>
"state"
</code>
: A boolean where
<code>
true
</code>
means the alert is enabled, and
<code>
false
</code>
means the alert is disabled. This is only relevant for alert log entries.
</li>
<li>
<code>
"global_threshold"
</code>
: The value of a threshold for alerts related to cluster or node objects.
</li>
<li>
<code>
"threshold"
</code>
: The value of a threshold for alerts related to a BDB object
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="log-entry-samples">
Log entry samples
</h2>
<p>
This section provides examples of log entries that include the
<a href="#severity">
<code>
rsyslog
</code>
configuration
</a>
to add the severity, timestamp, and machine name.
</p>
<h3 id="ephemeral-storage-passed-threshold">
Ephemeral storage passed threshold
</h3>
<h4 id="alert-on-log-entry-sample">
"Alert on" log entry sample
</h4>
<pre tabindex="0"><code>daemon.warning: Jun 14 14:49:20 node1 event_log[3464]:
{
"storage_util": 90.061643120001,
"global_threshold": "70",
"object": "node:1",
"state": true,
"time": 1434282560,
"type": "ephemeral_storage"
}
</code></pre>
<p>
In this example, the storage utilization on node 1 reached the value of ~90%, which triggered the alert for "Ephemeral storage has reached 70% of its capacity."
</p>
<p>
<strong>
Log entry components:
</strong>
</p>
<ul>
<li>
<code>
daemon.warning
</code>
- Severity of entry is
<code>
warning
</code>
</li>
<li>
<code>
Jun 14 14:49:20
</code>
- The timestamp of the event
</li>
<li>
<code>
node1
</code>
: Machine name
</li>
<li>
<code>
event_log
</code>
- Static text that always appears
</li>
<li>
<code>
[3464]
</code>
- Process ID
</li>
<li>
<code>
"storage_util":90.061643120001
</code>
- Current ephemeral storage utilization
</li>
<li>
<code>
"global_threshold":"70"
</code>
- The user-configured threshold above which the alert is raised
</li>
<li>
<code>
"object":"node:1"
</code>
- The object related to this alert
</li>
<li>
<code>
"state":true
</code>
- Current state of the alert
</li>
<li>
<code>
"time":1434282560
</code>
- Can be ignored
</li>
<li>
<code>
"type":"ephemeral_storage"
</code>
- The code name of this specific event. See
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
for more details.
</li>
</ul>
<h4 id="alert-off-log-entry-sample">
"Alert off" log entry sample
</h4>
<pre tabindex="0"><code>daemon.info: Jun 14 14:51:35 node1 event_log[3464]:
{
"storage_util":60.051723520008,
"global_threshold": "70",
"object": "node:1",
"state":false,
"time": 1434283480,
"type": "ephemeral_storage"
}
</code></pre>
<p>
This log entry is an example of when the alert for the node with ID 1 "Ephemeral storage has reached 70% of its capacity" has been turned off as result of storage utilization reaching the value of ~60%.
</p>
<p>
<strong>
Log entry components
</strong>
:
</p>
<ul>
<li>
<code>
daemon.info
</code>
- Severity of entry is
<code>
info
</code>
</li>
<li>
<code>
Jun 14 14:51:35
</code>
- The timestamp of the event
</li>
<li>
<code>
node1
</code>
- Machine name
</li>
<li>
<code>
event_log
</code>
- Static text that always appears
</li>
<li>
<code>
[3464]
</code>
- Process ID
</li>
<li>
<code>
"storage_util":60.051723520008
</code>
- Current ephemeral storage utilization
</li>
<li>
<code>
"global_threshold":"70"
</code>
- The user configured threshold above which the alert is raised (70% in this case)
</li>
<li>
<code>
"object":"node:1"
</code>
- The object related to this alert
</li>
<li>
<code>
"state":false
</code>
- Current state of the alert
</li>
<li>
<code>
"time":1434283480
</code>
- Can be ignored
</li>
<li>
<code>
"type":"ephemeral_storage"
</code>
- The code name identifier of this specific event. See
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
for more details.
</li>
</ul>
<h3 id="odd-number-of-nodes-with-a-minimum-of-three-nodes-alert">
Odd number of nodes with a minimum of three nodes alert
</h3>
<h4 id="alert-on-log-entry-sample-1">
"Alert on" log entry sample
</h4>
<pre tabindex="0"><code>daemon.warning: Jun 14 15:25:00 node1 event_log[8310]:
{
"object":"cluster",
"state": true,
"time": 1434284700,
"node_count": 1,
"type":"even_node_count"
}
</code></pre>
<p>
This log entry is an example of when the alert for "True high availability requires an odd number of nodes with a minimum of three nodes" has been turned on as result of the cluster having only one node.
</p>
<p>
<strong>
Log entry components:
</strong>
</p>
<ul>
<li>
<code>
daemon.warning
</code>
- Severity of entry is warning
</li>
<li>
<code>
Jun 14 15:25:00
</code>
- The timestamp of the event
</li>
<li>
<code>
node1
</code>
- Machine name
</li>
<li>
<code>
event_log
</code>
- Static text that always appears
</li>
<li>
<code>
[8310]
</code>
- Process ID
</li>
<li>
<code>
"object":"cluster"
</code>
- The object related to this alert
</li>
<li>
<code>
"state":true
</code>
- Current state of the alert
</li>
<li>
<code>
"time":1434284700
</code>
- Can be ignored
</li>
<li>
<code>
"node_count":1
</code>
- The number of nodes in the cluster
</li>
<li>
<code>
"type":"even_node_count"
</code>
- The code name identifier of this specific event. See
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
for more details.
</li>
</ul>
<h4 id="alert-off-log-entry-sample-1">
"Alert off" log entry sample
</h4>
<pre tabindex="0"><code>daemon.warning: Jun 14 15:30:40 node1 event_log[8310]:
{
"object":"cluster",
"state": false,
"time": 1434285200,
"node_count": 3,
"type":"even_node_count"
}
</code></pre>
<p>
This log entry is an example of when the alert for "True high availability requires an odd number of nodes with a minimum of three nodes" has been turned off as result of the cluster having 3 nodes.
</p>
<p>
<strong>
Log entry components:
</strong>
</p>
<ul>
<li>
<code>
daemon.warning
</code>
- Severity of entry is warning
</li>
<li>
<code>
Jun 14 15:30:40
</code>
- The timestamp of the event
</li>
<li>
<code>
node1
</code>
- Machine name
</li>
<li>
<code>
event_log
</code>
- Static text that always appears
</li>
<li>
<code>
[8310]
</code>
- Process ID
</li>
<li>
<code>
"object":"cluster"
</code>
- The object related to this alert
</li>
<li>
<code>
"state":false
</code>
- Current state of the alert
</li>
<li>
<code>
"time":1434285200
</code>
- Can be ignored
</li>
<li>
<code>
"node_count":3
</code>
- The number of nodes in the cluster
</li>
<li>
<code>
"type":"even_node_count"
</code>
- The code name of this specific event. See
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
for more details.
</li>
</ul>
<h3 id="node-has-insufficient-disk-space-for-aof-rewrite">
Node has insufficient disk space for AOF rewrite
</h3>
<h4 id="alert-on-log-entry-sample-2">
"Alert on" log entry sample
</h4>
<pre tabindex="0"><code>daemon.err: Jun 15 13:51:23 node1 event_log[34252]:
{
"used": 23457188,
"missing": 604602126,
"object": "node:1",
"free": 9867264,
"needed":637926578,
"state": true,
"time": 1434365483,
"disk": 705667072,
"type":"insufficient_disk_aofrw"
}
</code></pre>
<p>
This log entry is an example of when the alert for "Node has insufficient disk space for AOF rewrite" has been turned on as result of not having enough persistent storage disk space for AOF rewrite purposes. It is missing 604602126 bytes.
</p>
<p>
<strong>
Log entry components:
</strong>
</p>
<ul>
<li>
<code>
daemon.err
</code>
- Severity of entry is error
</li>
<li>
<code>
Jun 15 13:51:23
</code>
- The timestamp of the event
</li>
<li>
<code>
node1
</code>
- Machine name
</li>
<li>
<code>
event_log
</code>
- Static text that always appears
</li>
<li>
<code>
[34252]
</code>
- Process ID
</li>
<li>
<code>
"used":23457188
</code>
- The amount of disk space in bytes currently used for AOF files
</li>
<li>
<code>
"missing":604602126
</code>
- The amount of disk space in bytes that is currently missing for AOF rewrite purposes
</li>
<li>
<code>
"object":"node:1″
</code>
- The object related to this alert
</li>
<li>
<code>
"free":9867264
</code>
- The amount of disk space in bytes that is currently
free
</li>
<li>
<code>
"needed":637926578
</code>
- The amount of total disk space in bytes that is needed for AOF rewrite purposes
</li>
<li>
<code>
"state":true
</code>
- Current state of the alert
</li>
<li>
<code>
"time":1434365483
</code>
- Can be ignored
</li>
<li>
<code>
"disk":705667072
</code>
- The total size in bytes of the persistent storage
</li>
<li>
<code>
"type":"insufficient_disk_aofrw"
</code>
- The code name of this specific event. See
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
for more details.
</li>
</ul>
<h4 id="alert-off-log-entry-sample-2">
"Alert off" log entry sample
</h4>
<pre tabindex="0"><code>daemon.info: Jun 15 13:51:11 node1 event_log[34252]:
{
"used": 0, "missing":-21614592,
"object": "node:1",
"free": 21614592,
"needed": 0,
"state":false,
"time": 1434365471,
"disk": 705667072,
"type":"insufficient_disk_aofrw"
}
</code></pre>
<p>
<strong>
Log entry components:
</strong>
</p>
<ul>
<li>
<code>
daemon.info
</code>
- Severity of entry is info
</li>
<li>
<code>
Jun 15 13:51:11
</code>
- The timestamp of the event
</li>
<li>
<code>
node1
</code>
- Machine name
</li>
<li>
<code>
event_log
</code>
- Static text that always appears
</li>
<li>
<code>
[34252]
</code>
- Process ID
</li>
<li>
<code>
"used":0
</code>
- The amount of disk space in bytes currently used for AOF files
</li>
<li>
<code>
"missing":‐21614592
</code>
- The amount of disk space in bytes that is currently missing for AOF rewrite purposes. In this case, it is not missing because the number is negative.
</li>
<li>
<code>
"object":"node:1″
</code>
- The object related to this alert
</li>
<li>
<code>
"free":21614592
</code>
- The amount of disk space in bytes that is currently free
</li>
<li>
<code>
"needed":0
</code>
- The amount of total disk space in bytes that is needed for AOF rewrite purposes. In this case, no space is needed.
</li>
<li>
<code>
"state":false
</code>
- Current state of the alert
</li>
<li>
<code>
"time":1434365471
</code>
- Can be ignored
</li>
<li>
<code>
"disk":705667072
</code>
- The total size in bytes of the persistent storage
</li>
<li>
<code>
"type":"insufficient_disk_aofrw"
</code>
- The code name of this specific event. See
<a href="/docs/latest/operate/rs/7.4/clusters/logging/alerts-events/">
logged alerts and events
</a>
for more details.
</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/clusters/logging/rsyslog-logging/"/>
<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/debuginfo/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Cluster debug info requests
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the Redis Enterprise Software REST API /cluster/debuginfo requests.
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-cluster-debuginfo">
GET
</a>
</td>
<td>
<code>
/v1/cluster/debuginfo
</code>
</td>
<td>
Get debug info from all nodes and databases
</td>
</tr>
</tbody>
</table>
<h2 id="get-cluster-debuginfo">
Get cluster debug info
</h2>
<pre><code>GET /v1/cluster/debuginfo
</code></pre>
<p>
Downloads a tar file that contains debug info from all nodes and databases.
</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_debugging_info">
view_debugging_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/debuginfo
</code></pre>
<h3 id="get-response">
Response
</h3>
<p>
Downloads the debug info in a tar file called
<code>
filename.tar.gz
</code>
. Extract the files from the tar file to access the debug info for all nodes.
</p>
<h4 id="response-headers">
Response headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Content-Type
</td>
<td>
application/x-gzip
</td>
<td>
Media type of request/response body
</td>
</tr>
<tr>
<td>
Content-Length
</td>
<td>
653350
</td>
<td>
Length of the response body in octets
</td>
</tr>
<tr>
<td>
Content-Disposition
</td>
<td>
attachment; filename=debuginfo.tar.gz
</td>
<td>
Display response in browser or download as attachment
</td>
</tr>
</tbody>
</table>
<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>
Success.
</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>
Failed to get debug info.
</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/debuginfo/"/>
<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/tdigest.create.html | <section class="prose w-full py-12">
<h1 class="command-name">
TDIGEST.CREATE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TDIGEST.CREATE key [COMPRESSION compression]</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.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>
Allocates memory and initializes a new t-digest sketch.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
is key name for this new t-digest sketch.
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
COMPRESSION compression
</code>
</summary>
<p>
is a controllable tradeoff between accuracy and memory consumption. 100 is a common value for normal uses. 1000 is more accurate. If no value is passed by default the compression will be 100. For more information on scaling of accuracy versus the compression parameter see
<a href="https://www.sciencedirect.com/science/article/pii/S2665963820300403">
<em>
The t-digest: Efficient estimates of distributions
</em>
</a>
.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
-
<code>
OK
</code>
if executed correctly, or [] otherwise.
</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> TDIGEST.CREATE t COMPRESSION <span class="m">100</span>
</span></span><span class="line"><span class="cl">OK</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/tdigest.create/"/>
<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_group/.html | <section class="prose w-full py-12 max-w-none">
<h1>
BDB group object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents a group of databases with a shared memory pool
</p>
<p>
An API object that represents a group of databases that share a memory pool.
</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>
Cluster unique ID of the database group
</td>
</tr>
<tr>
<td>
members
</td>
<td>
array of strings
</td>
<td>
A list of UIDs of member databases (read-only)
</td>
</tr>
<tr>
<td>
memory_size
</td>
<td>
integer
</td>
<td>
The common memory pool size limit for all databases in the group, expressed in bytes
</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/bdb_group/"/>
<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/bloom/release-notes/redisbloom-2.2-release-notes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
RedisBloom 2.2 release notes
</h1>
<p class="text-lg -mt-5 mb-10">
BF.INFO returns bloom filter details. CF.INFO returns cuckoo filter details. Scalable bloom and cuckoo filters. Configurable bucket size for cuckoo filters. CMS.INCRBY returns count.
</p>
<h2 id="requirements">
Requirements
</h2>
<p>
RedisBloom v2.2.18 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="v2218-july-2022">
v2.2.18 (July 2022)
</h2>
<p>
This is a maintenance release for RedisBloom 2.2.
</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/RedisBloom/RedisBloom/issues/481">
#481
</a>
CF crashes on expansion 0
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/478">
#478
</a>
<a href="/docs/latest/commands/bf.info">
<code>
BF.INFO
</code>
</a>
reports an inaccurate result about the memory footprint
</li>
</ul>
</li>
</ul>
<h2 id="v2217-june-2022">
v2.2.17 (June 2022)
</h2>
<p>
This is a maintenance release for RedisBloom 2.2.
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/451">
#451
</a>
<a href="/docs/latest/commands/topk.incrby">
<code>
TOPK.INCRBY
</code>
</a>
: fix calculation when old fingerprint count is reduced to 0
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/462">
#462
</a>
<a href="/docs/latest/commands/cf.reserve">
<code>
CF.RESERVE
</code>
</a>
: fix potential crash on incorrect number of parameters
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/434">
#434
</a>
<a href="/docs/latest/commands/cf.insert">
<code>
CF.INSERT
</code>
</a>
: fix crash when capacity is negative
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/450">
#450
</a>
<a href="/docs/latest/commands/topk.incrby">
<code>
TOPK.INCRBY
</code>
</a>
: limit increment to 100,000 to prevent potential long freezes
</li>
</ul>
</li>
</ul>
<h2 id="v2215-may-2022">
v2.2.15 (May 2022)
</h2>
<p>
This is a maintenance release for RedisBloom 2.2.
</p>
<p>
Update urgency: None.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Enhancements:
</p>
<ul>
<li>
Added support for RedisBloom for AArch64 Linux
</li>
</ul>
</li>
</ul>
<h2 id="v2214-march-2022">
v2.2.14 (March 2022)
</h2>
<p>
This is a maintenance release for RedisBloom 2.2.
</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/RedisBloom/RedisBloom/pull/419">
#419
</a>
<code>
CMS.INCRBY
</code>
now returns an error on overflow
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/412">
#412
</a>
Fixed macOS build
</li>
</ul>
</li>
</ul>
<h2 id="v2212-february-2022">
v2.2.12 (February 2022)
</h2>
<p>
This is a maintenance release for RedisBloom 2.2.
</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/RedisBloom/RedisBloom/pull/392">
#392
</a>
Fixed a potential crash on Bloom filter expansion when loading from
<a href="/docs/latest/operate/oss_and_stack/management/persistence/">
AOF
</a>
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/404">
#404
</a>
Fixed a potential crash on Cuckoo filter when calling
<code>
CF.LOADCHUNK
</code>
on a filter with
<code>
EXPANSION
</code>
greater than 1
</li>
</ul>
</li>
</ul>
<h2 id="v229-november-2021">
v2.2.9 (November 2021)
</h2>
<p>
This is a maintenance release for RedisBloom 2.2.
</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>
<p>
<a href="https://github.com/RedisBloom/RedisBloom/pull/281">
#281
</a>
Memory leak when loading TOPK keys from RDB.
</p>
</li>
<li>
<p>
<a href="https://github.com/RedisBloom/RedisBloom/pull/303">
#303
</a>
<code>
CMS.INCRBY
</code>
for negative or non-number
</p>
</li>
<li>
<p>
<a href="https://github.com/RedisBloom/RedisBloom/pull/354">
#354
</a>
TOPK List Duplicate entries
</p>
</li>
<li>
<p>
<a href="https://github.com/RedisBloom/RedisBloom/pull/369">
#369
</a>
Free only latest filter on
<code>
CF.COMPACT
</code>
</p>
</li>
<li>
<p>
<a href="https://github.com/RedisBloom/RedisBloom/pull/371">
#371
</a>
<code>
CF.SCANDUMP
</code>
for cuckoo filter
</p>
</li>
<li>
<p>
<a href="https://github.com/RedisBloom/RedisBloom/pull/374">
#374
</a>
ReplicateVerbatim for
<code>
CF.LOADCHUNK
</code>
(similar to
<a href="https://github.com/RedisBloom/RedisBloom/pull/309">
#309
</a>
)
</p>
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/331">
#331
</a>
Add
<code>
WITHCOUNT
</code>
flag to
<code>
TOPK.LIST
</code>
</li>
</ul>
</li>
</ul>
<h2 id="v226-august-2021">
v2.2.6 (August 2021)
</h2>
<p>
This is a maintenance release for version 1.0.
</p>
<p>
Update urgency:
<code>
LOW
</code>
- No need to upgrade unless there are new features you want to use.
</p>
<p>
Details:
</p>
<ul>
<li>
Enhancements:
<ul>
<li>
#
<a href="https://github.com/redisbloom/redisbloom/issues/333">
333
</a>
Support inter shards TLS capability
</li>
</ul>
</li>
</ul>
<h2 id="v224-july-2020">
v2.2.4 (July 2020)
</h2>
<p>
Headlines:
</p>
<ul>
<li>
This release improves overall stability and provides fixes for found issues.
</li>
</ul>
<p>
Details:
</p>
<ul>
<li>
Bug fixes:
<ul>
<li>
#
<a href="https://github.com/redisbloom/redisbloom/issues/215">
215
</a>
Count-Min-Sketch CMS.INCRBY command to reply with correct min result.
</li>
<li>
#
<a href="https://github.com/redisbloom/redisbloom/issues/219">
219
</a>
Cuckoo Filter CF.DEBUG correct response formatting.
</li>
</ul>
</li>
</ul>
<h2 id="v223-july-2020">
v2.2.3 (July 2020)
</h2>
<p>
Headlines:
</p>
<ul>
<li>
This release improves overall stability and provides fixes for found issues.
</li>
</ul>
<p>
Details:
</p>
<ul>
<li>
Bug fixes:
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/217">
#217
</a>
Client hung on
<code>
BF.INSERT
</code>
with multiple new items when a non-scaling filter is full.
</li>
</ul>
</li>
</ul>
<h2 id="v222-march-2020">
v2.2.2 (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>
Minor enhancements:
<ul>
<li>
Bloom
<ul>
<li>
#
<a href="https://github.com/redisbloom/redisbloom/issues/180">
180
</a>
Removed the upper limit on Bloom Filter capacity.
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="v221-january-2020">
v2.2.1 (January 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>
Minor Enhancements:
<ul>
<li>
Bloom
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/179">
179
</a>
Allow storing filters with size over 4294967295 (UINT32_MAX). Now 64 bits.
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/177">
177
</a>
Prevent passing both
<code>
EXPANSION
</code>
<em>
and
</em>
<code>
NONSCALING
</code>
parameters to
<code>
BF.RESERVE
</code>
.
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="v220-december-2019">
v2.2.0 (December 2019)
</h2>
<ul>
<li>
<p>
Added functionality
</p>
<ul>
<li>
Bloom
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/149">
149
</a>
<code>
BF.INFO
</code>
returns details about a specific bloom filter
</li>
<li>
Scalable
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/153">
153
</a>
Ability to change the
<code>
EXPANSION
</code>
rate. This means each subsequent sub-filter will be
<code>
expansion
</code>
times larger as the previous one.
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/160">
160
</a>
Optimise the scaling up of filter according to the
<a href="https://core.ac.uk/download/pdf/55607643.pdf">
Scalable Bloom Filter
</a>
paper
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/161">
161
</a>
Optional
<code>
NONSCALING
</code>
argument to disable scaling. (This saves space since less hash functions are used)
</li>
</ul>
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/155">
155
</a>
Disabling rounding up functionality
</li>
</ul>
</li>
<li>
Cuckoo
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/149">
149
</a>
<code>
CF.INFO
</code>
returns details about a specific cuckoo filter
</li>
<li>
Scalable
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/138">
138
</a>
Configurable
<code>
EXPANSION
</code>
. When an additional filter is created, its size will be the size of the current filter multiplied by the
<code>
expansion
</code>
. Higher expansion rates will result in lower error rates.
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/142">
142
</a>
The maximum number of expansions limited to 32.
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/131">
131
</a>
Configurable
<code>
MAXITERATIONS
</code>
. Number of attempts to swap buckets before declaring filter as full and creating an additional filter.
</li>
</ul>
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/135">
135
</a>
Configurable
<code>
BUCKETSIZE
</code>
. Number of items in each bucket. Higher bucket size value improves the fill rate but result in a higher error rate and slightly slower operation speed.
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/142">
142
</a>
use of 64bit hash function
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/136">
136
</a>
expose compaction of filters in the API
</li>
</ul>
</li>
<li>
CMS
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/97">
97
</a>
<code>
CMS.INCRBY
</code>
returns count instead of ‘OK’
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>
Minor bug fixes
</p>
<ul>
<li>
Bloom
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/154">
154
</a>
Check error rate is 1< (cannot be equal)
</li>
</ul>
</li>
<li>
Cuckoo
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/134">
134
</a>
Added
<code>
CuckooInsert_MemAllocFailed
</code>
exception
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/130">
130
</a>
Number of deletes wasn’t saved to RDB
</li>
</ul>
</li>
<li>
General
<ul>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/117">
117
</a>
Using
<code>
RMUtil_RegisterWriteDenyOOMCmd
</code>
</li>
<li>
#
<a href="https://github.com/RedisBloom/RedisBloom/issues/121">
121
</a>
Moved
<code>
ReplicaVerbatim
</code>
to end of functions
</li>
</ul>
</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/redisbloom/redisbloom-2.2-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/rs/7.4/references/cli-utilities/crdb-cli/crdb/.html | <section class="prose w-full py-12 max-w-none">
<h1>
crdb-cli crdb commands
</h1>
<p class="text-lg -mt-5 mb-10">
Manage Active-Active databases.
</p>
<p>
Use
<code>
crdb-cli crdb
</code>
commands to manage Active-Active databases.
</p>
<h2 id="crdb-cli-crdb-commands">
<code>
crdb-cli crdb
</code>
commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
Command
</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/add-instance/">
add-instance
</a>
</td>
<td style="text-align:left">
Adds a peer replica to an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/create/">
create
</a>
</td>
<td style="text-align:left">
Creates an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/delete/">
delete
</a>
</td>
<td style="text-align:left">
Deletes an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/flush/">
flush
</a>
</td>
<td style="text-align:left">
Clears all keys from an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/get/">
get
</a>
</td>
<td style="text-align:left">
Shows the current configuration of an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/health-report/">
health-report
</a>
</td>
<td style="text-align:left">
Shows the health report of an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/list/">
list
</a>
</td>
<td style="text-align:left">
Shows a list of all Active-Active databases.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/purge-instance/">
purge-instance
</a>
</td>
<td style="text-align:left">
Deletes data from a local instance and removes it from the Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/remove-instance/">
remove-instance
</a>
</td>
<td style="text-align:left">
Removes a peer replica from an Active-Active database.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/update/">
update
</a>
</td>
<td style="text-align:left">
Updates the configuration of an Active-Active database.
</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/crdb-cli/crdb/"/>
<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/check/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Check all cluster nodes requests
</h1>
<p class="text-lg -mt-5 mb-10">
Requests that run checks on all cluster nodes.
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-cluster-check">
GET
</a>
</td>
<td>
<code>
/v1/cluster/check
</code>
</td>
<td>
Runs checks on all cluster nodes
</td>
</tr>
</tbody>
</table>
<h2 id="get-cluster-check">
Check all nodes
</h2>
<pre><code>GET /v1/cluster/check
</code></pre>
<p>
Runs the following checks on all cluster nodes:
</p>
<table>
<thead>
<tr>
<th>
Check name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
bootstrap_status
</td>
<td>
Verifies the local node's bootstrap process completed without errors.
</td>
</tr>
<tr>
<td>
services
</td>
<td>
Verifies all Redis Enterprise Software services are running.
</td>
</tr>
<tr>
<td>
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>
pidfiles
</td>
<td>
Verifies all active local shards have PID files.
</td>
</tr>
<tr>
<td>
capabilities
</td>
<td>
Verifies all binaries have the proper capability bits.
</td>
</tr>
<tr>
<td>
existing_sockets
</td>
<td>
Verifies sockets exist for all processes that require them.
</td>
</tr>
<tr>
<td>
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>
tcp_connectivity
</td>
<td>
Verifies this node can connect to all other alive nodes.
</td>
</tr>
</tbody>
</table>
<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_all_nodes_checks">
view_all_nodes_checks
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /cluster/check
</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 JSON array with results from all nodes.
</p>
<p>
When errors occur, the server returns a JSON object with
<code>
result: false
</code>
and an
<code>
error
</code>
field that provides additional information for each node that had an error. If an error occurs during a check, the
<code>
error
</code>
field only includes a message for the first check that fails on each node.
</p>
<p>
Possible
<code>
error
</code>
messages:
</p>
<ul>
<li>
"bootstrap request to cnm_http failed,resp_code: ...,resp_content: ..."
</li>
<li>
"process ... is not running or not responding (...)"
</li>
<li>
"could not communicate with 'supervisorctl': ..."
</li>
<li>
"connectivity check failed retrieving ports for testing"
</li>
</ul>
<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">"cluster_test_result"</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">"nodes"</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">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"result"</span><span class="p">:</span> <span class="kc">true</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">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"result"</span><span class="p">:</span> <span class="kc">true</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">"node_uid"</span><span class="p">:</span> <span class="s2">"3"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"result"</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">"error"</span><span class="p">:</span> <span class="s2">"process alert_mgr is not running or not responding ([Errno 111] Connection refused)"</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>
<h3 id="get-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">
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/cluster/check/"/>
<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/data-types/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Data type commands compatibility
</h1>
<p class="text-lg -mt-5 mb-10">
Data type commands compatibility (bitmaps, geospatial indices, hashes, HyperLogLogs, lists, sets, sorted sets, streams, strings).
</p>
<p>
The following tables show which Redis Community Edition data type commands are compatible with standard and Active-Active databases in Redis Enterprise Software and Redis Cloud.
</p>
<h2 id="bitmap-commands">
Bitmap commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bitcount/">
BITCOUNT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bitfield/">
BITFIELD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bitfield_ro/">
BITFIELD_RO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bitop/">
BITOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bitpos/">
BITPOS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/getbit/">
GETBIT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/setbit/">
SETBIT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="geospatial-indices-commands">
Geospatial indices commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/geoadd/">
GEOADD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/geodist/">
GEODIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/geohash/">
GEOHASH
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/geopos/">
GEOPOS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/georadius/">
GEORADIUS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/georadius_ro/">
GEORADIUS_RO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/georadiusbymember/">
GEORADIUSBYMEMBER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/georadiusbymember_ro/">
GEORADIUSBYMEMBER_RO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/geosearch/">
GEOSEARCH
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/geosearchstore/">
GEOSEARCHSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="hash-commands">
Hash commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hdel/">
HDEL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hexists/">
HEXISTS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hget/">
HGET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hgetall/">
HGETALL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hincrby/">
HINCRBY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hincrbyfloat/">
HINCRBYFLOAT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hkeys/">
HKEYS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hlen/">
HLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hmget/">
HMGET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hmset/">
HMSET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v4.0.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hrandfield/">
HRANDFIELD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hscan/">
HSCAN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hset/">
HSET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hsetnx/">
HSETNX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hstrlen/">
HSTRLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/hvals/">
HVALS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="hyperloglog-commands">
HyperLogLog commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/pfadd/">
PFADD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/pfcount/">
PFCOUNT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/pfdebug/">
PFDEBUG
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/pfmerge/">
PFMERGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/pfselftest/">
PFSELFTEST
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="list-commands">
List commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/blmove/">
BLMOVE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/blmpop/">
BLMPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/blpop/">
BLPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/brpop/">
BRPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/brpoplpush/">
BRPOPLPUSH
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lindex/">
LINDEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/linsert/">
LINSERT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/llen/">
LLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lmove/">
LMOVE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lmpop/">
LMPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lpop/">
LPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lpos/">
LPOS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lpush/">
LPUSH
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lpushx/">
LPUSHX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lrange/">
LRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lrem/">
LREM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lset/">
LSET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/ltrim/">
LTRIM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/rpop/">
RPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/rpoplpush/">
RPOPLPUSH
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/rpush/">
RPUSH
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/rpushx/">
RPUSHX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="set-commands">
Set commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sadd/">
SADD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/scard/">
SCARD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sdiff/">
SDIFF
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sdiffstore/">
SDIFFSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sinter/">
SINTER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sintercard/">
SINTERCARD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sinterstore/">
SINTERSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sismember/">
SISMEMBER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/smembers/">
SMEMBERS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sismember/">
SMISMEMBER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/smove/">
SMOVE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/spop/">
SPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/srandmember/">
SRANDMEMBER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/srem/">
SREM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sscan/">
SSCAN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sunion/">
SUNION
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sunionstore/">
SUNIONSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="sorted-set-commands">
Sorted set commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bzmpop/">
BZMPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bzpopmax/">
BZPOPMAX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bzpopmin/">
BZPOPMIN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zadd/">
ZADD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zcard/">
ZCARD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zcount/">
ZCOUNT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zdiff/">
ZDIFF
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zdiffstore/">
ZDIFFSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zincrby/">
ZINCRBY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zinter/">
ZINTER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zintercard/">
ZINTERCARD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zinterstore/">
ZINTERSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zlexcount/">
ZLEXCOUNT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zmpop/">
ZMPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zmscore/">
ZMSCORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zpopmax/">
ZPOPMAX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zpopmin/">
ZPOPMIN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrandmember/">
ZRANDMEMBER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrange/">
ZRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrangebylex/">
ZRANGEBYLEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrangebyscore/">
ZRANGEBYSCORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrangestore/">
ZRANGESTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrank/">
ZRANK
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrem/">
ZREM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zremrangebylex/">
ZREMRANGEBYLEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zremrangebyrank/">
ZREMRANGEBYRANK
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zremrangebyscore/">
ZREMRANGEBYSCORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrevrange/">
ZREVRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrevrangebylex/">
ZREVRANGEBYLEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrevrangebyscore/">
ZREVRANGEBYSCORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zrevrank/">
ZREVRANK
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zscan/">
ZSCAN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zscore/">
ZSCORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zunion/">
ZUNION
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/zunionstore/">
ZUNIONSTORE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="stream-commands">
Stream commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xack/">
XACK
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xadd/">
XADD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xautoclaim/">
XAUTOCLAIM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xclaim/">
XCLAIM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xdel/">
XDEL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xgroup/">
XGROUP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xinfo/">
XINFO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xlen/">
XLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xpending/">
XPENDING
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xrange/">
XRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xread/">
XREAD
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xreadgroup/">
XREADGROUP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xrevrange/">
XREVRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xsetid/">
XSETID
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/xtrim/">
XTRIM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="string-commands">
String commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 10em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/append/">
APPEND
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/decr/">
DECR
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/decrby/">
DECRBY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/get/">
GET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/getdel/">
GETDEL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/getex/">
GETEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active*
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active*
</nobr>
</span>
</td>
<td style="text-align:left">
*Not supported for HyperLogLog.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/getrange/">
GETRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/getset/">
GETSET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v6.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/incr/">
INCR
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/incrby/">
INCRBY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/incrbyfloat/">
INCRBYFLOAT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lcs/">
LCS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/mget/">
MGET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/mset/">
MSET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/msetnx/">
MSETNX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/psetex/">
PSETEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/set/">
SET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/setex/">
SETEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/setnx/">
SETNX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/setrange/">
SETRANGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
STRALGO
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v7.0.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/strlen/">
STRLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
✅ Standard
</span>
<br/>
<span title="Supported">
<nobr>
✅ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/substr/">
SUBSTR
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
❌ Standard
</span>
<br/>
<span title="Not supported">
<nobr>
❌ Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v2.0.0.
</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/data-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/operate/oss_and_stack/stack-with-enterprise/deprecated-features/graph/graph-quickstart/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Graph quick start
</h1>
<p class="text-lg -mt-5 mb-10">
Graph quick start
</p>
<div class="banner-article rounded-md">
<p>
Redis, Inc. has announced the end of life of RedisGraph. We will carry out the process gradually and in accordance with our commitment to our customers. See
<a href="https://redis.io/blog/redisgraph-eol/">
details
</a>
.
</p>
</div>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
For this quick start tutorial, you need:
</p>
<ul>
<li>
<p>
A Redis database with the RedisGraph module enabled. You can use either:
</p>
<ul>
<li>
<p>
A
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/stack-quickstart/">
Redis Cloud
</a>
database
</p>
</li>
<li>
<p>
A
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-database/">
Redis Enterprise Software
</a>
database
</p>
</li>
</ul>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/">
<code>
redis-cli
</code>
</a>
command-line tool
</p>
</li>
<li>
<p>
<a href="https://github.com/redis/redis-py">
<code>
redis-py
</code>
</a>
client library v4.1.0 or later
</p>
</li>
</ul>
<h2 id="graph-with-redis-cli">
Graph with
<code>
redis-cli
</code>
</h2>
<p>
To begin,
<a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/#connect-to-a-database">
connect to your database
</a>
with
<code>
redis-cli
</code>
.
</p>
<h3 id="create-a-graph">
Create a graph
</h3>
<p>
When you create a graph, you can define nodes and the relationships between them with this format:
</p>
<p>
<code>
(:<node 1>)-[:<relationship>]->(:<node 2>)
</code>
</p>
<p>
To define multiple nodes and relationships in a single creation query, separate the entries with commas.
</p>
<p>
For example, use the
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/commands/graph.query.md#create">
<code>
CREATE
</code>
</a>
query to create a new graph of motorcycle riders and teams participating in the MotoGP league:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Labels added: 2"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Nodes created: 6"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"Properties set: 6"</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"Relationships created: 3"</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="s2">"Query internal execution time: 0.385472 milliseconds"</span>
</span></span></code></pre>
</div>
<h3 id="add-nodes">
Add nodes
</h3>
<p>
You can add new nodes to a previously created graph:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"CREATE (:Rider {name:'Jorge Lorenzo'})"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Nodes created: 1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Properties set: 1"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"Query internal execution time: 0.185841 milliseconds"</span>
</span></span></code></pre>
</div>
<h3 id="add-relationships">
Add relationships
</h3>
<p>
To create new relationships between nodes of a graph:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"MATCH (r:Rider), (t:Team) WHERE r.name = 'Jorge Lorenzo' and t.name = 'Honda' CREATE (r)-[:rides]->(t)"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Relationships created: 1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"Query internal execution time: 0.356578 milliseconds"</span>
</span></span></code></pre>
</div>
<h3 id="query-the-graph">
Query the graph
</h3>
<p>
After you create a graph, you can use the
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/commands/graph.query.md">
<code>
GRAPH.QUERY
</code>
</a>
command to query the graph's data.
</p>
<p>
The following example returns which motorcycle riders compete for team Yamaha:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r,t"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"r"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"t"</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"id"</span>
</span></span><span class="line"><span class="cl"> 2<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">"labels"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Rider"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"properties"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 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">"Valentino Rossi"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"id"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"labels"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Team"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"properties"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 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">"Yamaha"</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Query internal execution time: 0.500535 milliseconds"</span>
</span></span></code></pre>
</div>
<p>
You can also use
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/commands/graph.query.md#functions">
functions
</a>
to create more complex queries.
</p>
<p>
For example, you can use the
<code>
count
</code>
function to check how many riders represent team Honda:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"MATCH (r:Rider)-[:rides]->(t:Team {name:'Honda'}) RETURN count(r)"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"count(r)"</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"2"</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Query internal execution time: 0.445760 milliseconds"</span>
</span></span></code></pre>
</div>
<h3 id="delete-nodes">
Delete nodes
</h3>
<p>
You can use the
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/commands/graph.query.md#delete">
<code>
DELETE
</code>
</a>
query to remove a specific node and its relationships from the graph:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"MATCH (r:Rider {name: 'Dani Pedrosa'}) DELETE r"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Nodes deleted: 1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Relationships deleted: 1"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"Query internal execution time: 0.276815 milliseconds"</span>
</span></span></code></pre>
</div>
<h3 id="delete-relationships">
Delete relationships
</h3>
<p>
You can also use the
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/commands/graph.query.md#delete">
<code>
DELETE
</code>
</a>
query to delete a node's relationships without removing any nodes:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.QUERY MotoGP <span class="s2">"MATCH (:Rider {name: 'Valentino Rossi'})-[r:rides]->() DELETE r"</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"Relationships deleted: 1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"Cached execution: 0"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"Query internal execution time: 0.348346 milliseconds"</span>
</span></span></code></pre>
</div>
<h3 id="delete-a-graph">
Delete a graph
</h3>
<p>
To delete an entire graph, including all nodes and relationships, run the
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/commands/graph.delete.md">
<code>
GRAPH.DELETE
</code>
</a>
command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:12543> GRAPH.DELETE MotoGP
</span></span><span class="line"><span class="cl"><span class="s2">"Graph removed, internal execution time: 0.013138 milliseconds"</span>
</span></span></code></pre>
</div>
<h2 id="graph-with-python">
Graph with Python
</h2>
<p>
If you want to use graphs within an application, you can use one of these
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/docs/clients.md">
client libraries
</a>
.
</p>
<p>
The following example uses the Redis Python client library
<a href="https://github.com/redis/redis-py">
redis-py
</a>
, which supports graph commands as of v4.1.0.
</p>
<p>
This Python code creates a graph that represents friendships between users on a social media website. It also shows how to run queries and change relationships between users.
</p>
<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 class="kn">from</span> <span class="nn">redis.commands.graph.edge</span> <span class="kn">import</span> <span class="n">Edge</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.graph.node</span> <span class="kn">import</span> <span class="n">Node</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Connect to a database</span>
</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">host</span><span class="o">=</span><span class="s2">"<endpoint>"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="s2">"<port>"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">password</span><span class="o">=</span><span class="s2">"<password>"</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 nodes that represent users</span>
</span></span><span class="line"><span class="cl"><span class="n">users</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">"Alex"</span><span class="p">:</span> <span class="n">Node</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"Person"</span><span class="p">,</span> <span class="n">properties</span><span class="o">=</span><span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Alex"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">35</span><span class="p">}),</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Jun"</span><span class="p">:</span> <span class="n">Node</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"Person"</span><span class="p">,</span> <span class="n">properties</span><span class="o">=</span><span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Jun"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">33</span><span class="p">}),</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Taylor"</span><span class="p">:</span> <span class="n">Node</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"Person"</span><span class="p">,</span> <span class="n">properties</span><span class="o">=</span><span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Taylor"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">28</span><span class="p">}),</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"Noor"</span><span class="p">:</span> <span class="n">Node</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"Person"</span><span class="p">,</span> <span class="n">properties</span><span class="o">=</span><span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Noor"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">41</span><span class="p">})</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Define a graph called SocialMedia</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">graph</span><span class="p">(</span><span class="s2">"SocialMedia"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Add users to the graph as nodes</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">users</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
</span></span><span class="line"><span class="cl"> <span class="n">social_graph</span><span class="o">.</span><span class="n">add_node</span><span class="p">(</span><span class="n">users</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="c1"># Add relationships between user nodes</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Alex"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Jun"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># Make the relationship bidirectional</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Jun"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Alex"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Jun"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Taylor"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Taylor"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Jun"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Jun"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Noor"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Noor"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Jun"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Alex"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Noor"</span><span class="p">])</span> <span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">add_edge</span><span class="p">(</span> <span class="n">Edge</span><span class="p">(</span><span class="n">users</span><span class="p">[</span><span class="s2">"Noor"</span><span class="p">],</span> <span class="s2">"friends"</span><span class="p">,</span> <span class="n">users</span><span class="p">[</span><span class="s2">"Alex"</span><span class="p">])</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 the graph in the database</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">commit</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Query the graph to find out how many friends Alex has</span>
</span></span><span class="line"><span class="cl"><span class="n">result1</span> <span class="o">=</span> <span class="n">social_graph</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s2">"MATCH (p1:Person {name: 'Alex'})-[:friends]->(p2:Person) RETURN count(p2)"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="s2">"Alex's original friend count:"</span><span class="p">,</span> <span class="n">result1</span><span class="o">.</span><span class="n">result_set</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Delete a relationship without deleting any user nodes</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s2">"MATCH (:Person {name: 'Alex'})<-[f:friends]->(:Person {name: 'Jun'}) DELETE f"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Query the graph again to see Alex's updated friend count</span>
</span></span><span class="line"><span class="cl"><span class="n">result2</span> <span class="o">=</span> <span class="n">social_graph</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s2">"MATCH (p1:Person {name: 'Alex'})-[:friends]->(p2:Person) RETURN count(p2)"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="s2">"Alex's updated friend count:"</span><span class="p">,</span> <span class="n">result2</span><span class="o">.</span><span class="n">result_set</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Delete the entire graph</span>
</span></span><span class="line"><span class="cl"><span class="n">social_graph</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
</span></span></code></pre>
</div>
<p>
Example output:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ ./quick_start.py
</span></span><span class="line"><span class="cl">Alex's original friend count: [[2]]
</span></span><span class="line"><span class="cl">Alex's updated friend count: [[1]]
</span></span></code></pre>
</div>
<h2 id="visualize-graphs-with-redis-insight">
Visualize graphs with Redis Insight
</h2>
<p>
You can use the
<a href="/docs/latest/develop/tools/insight/">
Redis Insight
</a>
workbench to visualize the relationships between the nodes of your graph.
</p>
<ol>
<li>
<p>
Connect to your database with Redis Insight. You can
<a href="/docs/latest/develop/connect/insight/#add-a-standalone-redis-database">
connect manually
</a>
or use the
<a href="/docs/latest/develop/connect/insight/#auto-discovery-for-redis-cloud-databases">
auto-discovery
</a>
feature.
</p>
</li>
<li>
<p>
Select the
<strong>
Workbench
</strong>
button:
</p>
<a href="/docs/latest/images/ri/icon-workbench.png" sdata-lightbox="/images/ri/icon-workbench.png">
<img alt="The Workbench icon" src="/docs/latest/images/ri/icon-workbench.png" width="30px"/>
</a>
</li>
<li>
<p>
Enter a graph query in the text editor.
</p>
<p>
For example, this query returns all nodes and relationships in the graph:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GRAPH.QUERY MotoGP <span class="s2">"MATCH (n) RETURN n"</span>
</span></span></code></pre>
</div>
</li>
<li>
<p>
Select
<strong>
Run
</strong>
:
</p>
<a href="/docs/latest/images/ri/icon-run-command.png" sdata-lightbox="/images/ri/icon-run-command.png">
<img alt="The Run command icon" src="/docs/latest/images/ri/icon-run-command.png" width="30px"/>
</a>
</li>
</ol>
<p>
After you run a query, the output log displays a visual representation of your graph's nodes and relationships:
</p>
<a href="/docs/latest/images/modules/visualize-graph.png" sdata-lightbox="/images/modules/visualize-graph.png">
<img alt="Visualize a graph with Redis Insight workbench." src="/docs/latest/images/modules/visualize-graph.png"/>
</a>
<h2 id="more-info">
More info
</h2>
<ul>
<li>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/graph/commands/">
Graph commands
</a>
</li>
<li>
<a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/docs/clients.md">
RedisGraph client libraries
</a>
</li>
<li>
<a href="https://github.com/RedisGraph/RedisGraph/tree/master/docs/docs">
RedisGraph documentation on GitHub
</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/operate/oss_and_stack/stack-with-enterprise/deprecated-features/graph/graph-quickstart/"/>
<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/reference/cli/redis-di-delete-all-contexts/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di delete-all-contexts
</h1>
<p class="text-lg -mt-5 mb-10">
Deletes all contexts
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di delete-all-contexts [OPTIONS]
</code></pre>
<h2 id="options">
Options
</h2>
<ul>
<li>
<p>
<code>
loglevel
</code>
:
</p>
<ul>
<li>
Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
</li>
<li>
Default:
<code>
info
</code>
</li>
<li>
Usage:
<code>
--loglevel -log-level
</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-all-contexts [OPTIONS]
Deletes all contexts
Options:
-log-level, --loglevel [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/write-behind/reference/cli/redis-di-delete-all-contexts/"/>
<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/legacy-release-notes/rs-5-2-june-2018/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software Release Notes 5.2 (June 2018)
</h1>
<p>
Redis Enterprise Software (RS) 5.2 is now available. Key features
include new data types and casual consistency for active-active (also
known as the Redis CRDT or CRDB Conflict-free Replicated Database), as
well as enhanced security features.
</p>
<h2 id="overview">
Overview
</h2>
<p>
If you are upgrading from a previous version, make sure to review the
upgrade instructions before beginning the upgrade process. You can
upgrade to RS 5.2 from RS 4.5 and above. If you have a version older
than 4.5, you should first upgrade to version 5.0 (or at least
4.5).
</p>
<h2 id="new-features">
New features
</h2>
<h3 id="activeactive-redis-crdb-supports-sorted-sets-and-lists">
Active-Active Redis (CRDB) supports sorted sets and lists
</h3>
<p>
RS 5.2 adds active-active Redis (CRDB) support for Sorted Sets and
Lists. Now all major Redis data types are supported with CRDT, so you
can use Redis Enterprise in an active-active manner for all your Redis
use cases, with seamless conflict resolution.
<a href="/docs/latest/operate/rs/databases/active-active/develop/develop-for-aa/">
Click here
</a>
for more information about how to develop applications with
geo-replicated CRDBs.
</p>
<h3 id="causal-consistency-in-activeactive-redis-crdb">
Causal consistency in Active-Active Redis (CRDB)
</h3>
<p>
casual consistency in active-active Redis (CRDB) guarantees that the
order of operations on a specific key will be maintained across all CRDB
instances. For instance, if operations A and B were applied on the same
key, and B was performed after the effect of A was observed by the CRDB
instance that initiated B, then all CRDB instances would observe the
effect of A before observing the effect of B.
</p>
<p>
This way, any causal relationship between operations on the same key is
also observed and maintained by every replica. Such capability is
important for various applications, e.g. social network status updates
or chat applications (assuring that the chronology of messages doesn't
get mixed up). For more information,
<a href="/docs/latest/operate/rs/databases/active-active/causal-consistency/">
click
here
</a>
.
</p>
<h3 id="enhanced-security-features">
Enhanced security features
</h3>
<ul>
<li>
<strong>
Admin action audit trail
</strong>
</li>
</ul>
<p>
Management actions performed with Redis Software are audited in order
to fulfill two major objectives: (1) make sure that system management tasks
are appropriately performed and/or monitored by the Administrator(s),
and (2) facilitate compliance with regulatory standards such as HIPAA,
SOC2, PCI, etc.
</p>
<p>
In order to fulfill both objectives, audit records contain the
following information: (1) who performed the action, (2) what exactly
was the performed action, (3) when the action was performed, and (4)
whether the action succeeded.
</p>
<p>
To get the list of audit records/events, one can use the REST API or
the Log page in the UI; the Log page displays the system and user events
regarding alerts, notifications and
configurations.
</p>
<ul>
<li>
<strong>
Ability to disable TLS versions
</strong>
</li>
</ul>
<p>
Version 5.2 introduces the option to set the minimum TLS version that
can be used for encrypting the various flows. You can do so using the
REST API or the following rladmin commands:
</p>
<ul>
<li>
For the management UI and the REST API:
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin> cluster config min_control_TLS_version <span class="o">[</span>version, e.g. 1.2<span class="o">]</span>
</span></span></code></pre>
</div>
<ul>
<li>
For the data path encryption:
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin> cluster config min_data_TLS_version <span class="o">[</span>version, e.g. 1.2<span class="o">]</span>
</span></span></code></pre>
</div>
<p>
Note that communications that use older TLS versions will not be
allowed.
</p>
<ul>
<li>
<strong>
HTTPS enforcement
</strong>
</li>
</ul>
<p>
With this feature, you can restrict REST API access to only those
using HTTPS. In order to do so, use the REST API or the following
rladmin command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin> cluster config http_support <span class="o">[</span>disabled <span class="p">|</span> enabled<span class="o">]</span>
</span></span></code></pre>
</div>
<h2 id="additional-capabilities">
Additional capabilities
</h2>
<ul>
<li>
Support for Redis version 4.0.9
</li>
<li>
Fixes for Redis important security issues related to the Lua
scripting engine
</li>
</ul>
<h2 id="information">
Information
</h2>
<ul>
<li>
The end-of-service-life (EOSL) for Redis Enterprise Software 4.4.X
is June 30th, 2018, in accordance with our
<a href="/docs/latest/operate/rs/installing-upgrading/product-lifecycle/">
published
policy
</a>
.
We recommend that customers running version 4.4 or below
upgrade to the latest version.
</li>
</ul>
<h2 id="important-fixes">
Important fixes
</h2>
<ul>
<li>
<p>
RS19755 - Added the ability to enforce HTTPS communication when
accessing REST API
</p>
</li>
<li>
<p>
RS19571 - Fixed RHEL installation when FIPS mode is
enabled
</p>
</li>
<li>
<p>
RS19490 - Fixed a failure while upgrading from 4.5 to
5.0.2
</p>
</li>
<li>
<p>
RS19475 - Added the ability to disable TLS versions for the
control and data paths
</p>
</li>
<li>
<p>
RS18712 - Fixed a failure in endpoint failover
</p>
</li>
<li>
<p>
RS17208 - Added an option to disable Redis commands via Rest
API
</p>
</li>
<li>
<p>
RS14973 - Updated NGINX.conf template to turn off exposing the
server version
</p>
</li>
<li>
<p>
RS11181 - Set file permissions of log files, redis-conf files, rdb
files and their rotations to "640"
</p>
</li>
</ul>
<h2 id="known-limitations">
Known limitations
</h2>
<ul>
<li>
After creating Redis Enterprise CRDBs which "Require SSL for CRDB
communication only," one can set definitions via Rest API to
activate "Require SSL for All Communication" without providing a
certificate. In such case, connections to the cluster will be
blocked.
</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-2-june-2018/"/>
<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/persistence/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis persistence
</h1>
<p class="text-lg -mt-5 mb-10">
How Redis writes data to disk
</p>
<p>
Persistence refers to the writing of data to durable storage, such as a solid-state disk (SSD). Redis provides a range of persistence options. These include:
</p>
<ul>
<li>
<strong>
RDB
</strong>
(Redis Database): RDB persistence performs point-in-time snapshots of your dataset at specified intervals.
</li>
<li>
<strong>
AOF
</strong>
(Append Only File): AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the Redis protocol itself.
</li>
<li>
<strong>
No persistence
</strong>
: You can disable persistence completely. This is sometimes used when caching.
</li>
<li>
<strong>
RDB + AOF
</strong>
: You can also combine both AOF and RDB in the same instance.
</li>
</ul>
<p>
If you'd rather not think about the tradeoffs between these different persistence strategies, you may want to consider
<a href="/docs/latest/operate/rs/databases/configure/database-persistence/">
Redis Enterprise's persistence options
</a>
, which can be pre-configured using a UI.
</p>
<p>
To learn more about how to evaluate your Redis persistence strategy, read on.
</p>
<h2 id="rdb-advantages">
RDB advantages
</h2>
<ul>
<li>
RDB is a very compact single-file point-in-time representation of your Redis data. RDB files are perfect for backups. For instance you may want to archive your RDB files every hour for the latest 24 hours, and to save an RDB snapshot every day for 30 days. This allows you to easily restore different versions of the data set in case of disasters.
</li>
<li>
RDB is very good for disaster recovery, being a single compact file that can be transferred to far data centers, or onto Amazon S3 (possibly encrypted).
</li>
<li>
RDB maximizes Redis performances since the only work the Redis parent process needs to do in order to persist is forking a child that will do all the rest. The parent process will never perform disk I/O or alike.
</li>
<li>
RDB allows faster restarts with big datasets compared to AOF.
</li>
<li>
On replicas, RDB supports
<a href="/docs/latest/operate/oss_and_stack/management/replication/#partial-resynchronizations-after-restarts-and-failovers">
partial resynchronizations after restarts and failovers
</a>
.
</li>
</ul>
<h2 id="rdb-disadvantages">
RDB disadvantages
</h2>
<ul>
<li>
RDB is NOT good if you need to minimize the chance of data loss in case Redis stops working (for example after a power outage). You can configure different
<em>
save points
</em>
where an RDB is produced (for instance after at least five minutes and 100 writes against the data set, you can have multiple save points). However you'll usually create an RDB snapshot every five minutes or more, so in case of Redis stopping working without a correct shutdown for any reason you should be prepared to lose the latest minutes of data.
</li>
<li>
RDB needs to fork() often in order to persist on disk using a child process. fork() can be time consuming if the dataset is big, and may result in Redis stopping serving clients for some milliseconds or even for one second if the dataset is very big and the CPU performance is not great. AOF also needs to fork() but less frequently and you can tune how often you want to rewrite your logs without any trade-off on durability.
</li>
</ul>
<h2 id="aof-advantages">
AOF advantages
</h2>
<ul>
<li>
Using AOF Redis is much more durable: you can have different fsync policies: no fsync at all, fsync every second, fsync at every query. With the default policy of fsync every second, write performance is still great. fsync is performed using a background thread and the main thread will try hard to perform writes when no fsync is in progress, so you can only lose one second worth of writes.
</li>
<li>
The AOF log is an append-only log, so there are no seeks, nor corruption problems if there is a power outage. Even if the log ends with a half-written command for some reason (disk full or other reasons) the redis-check-aof tool is able to fix it easily.
</li>
<li>
Redis is able to automatically rewrite the AOF in background when it gets too big. The rewrite is completely safe as while Redis continues appending to the old file, a completely new one is produced with the minimal set of operations needed to create the current data set, and once this second file is ready Redis switches the two and starts appending to the new one.
</li>
<li>
AOF contains a log of all the operations one after the other in an easy to understand and parse format. You can even easily export an AOF file. For instance even if you've accidentally flushed everything using the
<a href="/commands/flushall">
<code>
FLUSHALL
</code>
</a>
command, as long as no rewrite of the log was performed in the meantime, you can still save your data set just by stopping the server, removing the latest command, and restarting Redis again.
</li>
</ul>
<h2 id="aof-disadvantages">
AOF disadvantages
</h2>
<ul>
<li>
AOF files are usually bigger than the equivalent RDB files for the same dataset.
</li>
<li>
AOF can be slower than RDB depending on the exact fsync policy. In general with fsync set to
<em>
every second
</em>
performance is still very high, and with fsync disabled it should be exactly as fast as RDB even under high load. Still RDB is able to provide more guarantees about the maximum latency even in the case of a huge write load.
</li>
</ul>
<p>
<strong>
Redis < 7.0
</strong>
</p>
<ul>
<li>
AOF can use a lot of memory if there are writes to the database during a rewrite (these are buffered in memory and written to the new AOF at the end).
</li>
<li>
All write commands that arrive during rewrite are written to disk twice.
</li>
<li>
Redis could freeze writing and fsyncing these write commands to the new AOF file at the end of the rewrite.
</li>
</ul>
<h2 id="ok-so-what-should-i-use">
Ok, so what should I use?
</h2>
<p>
The general indication you should use both persistence methods is if
you want a degree of data safety comparable to what PostgreSQL can provide you.
</p>
<p>
If you care a lot about your data, but still can live with a few minutes of
data loss in case of disasters, you can simply use RDB alone.
</p>
<p>
There are many users using AOF alone, but we discourage it since to have an
RDB snapshot from time to time is a great idea for doing database backups,
for faster restarts, and in the event of bugs in the AOF engine.
</p>
<p>
The following sections will illustrate a few more details about the two persistence models.
</p>
<h2 id="snapshotting">
Snapshotting
</h2>
<p>
By default Redis saves snapshots of the dataset on disk, in a binary
file called
<code>
dump.rdb
</code>
. You can configure Redis to have it save the
dataset every N seconds if there are at least M changes in the dataset,
or you can manually call the
<a href="/commands/save">
<code>
SAVE
</code>
</a>
or
<a href="/commands/bgsave">
<code>
BGSAVE
</code>
</a>
commands.
</p>
<p>
For example, this configuration will make Redis automatically dump the
dataset to disk every 60 seconds if at least 1000 keys changed:
</p>
<pre><code>save 60 1000
</code></pre>
<p>
This strategy is known as
<em>
snapshotting
</em>
.
</p>
<h3 id="how-it-works">
How it works
</h3>
<p>
Whenever Redis needs to dump the dataset to disk, this is what happens:
</p>
<ul>
<li>
<p>
Redis
<a href="http://linux.die.net/man/2/fork">
forks
</a>
. We now have a child
and a parent process.
</p>
</li>
<li>
<p>
The child starts to write the dataset to a temporary RDB file.
</p>
</li>
<li>
<p>
When the child is done writing the new RDB file, it replaces the old
one.
</p>
</li>
</ul>
<p>
This method allows Redis to benefit from copy-on-write semantics.
</p>
<h2 id="append-only-file">
Append-only file
</h2>
<p>
Snapshotting is not very durable. If your computer running Redis stops,
your power line fails, or you accidentally
<code>
kill -9
</code>
your instance, the
latest data written to Redis will be lost. While this may not be a big
deal for some applications, there are use cases for full durability, and
in these cases Redis snapshotting alone is not a viable option.
</p>
<p>
The
<em>
append-only file
</em>
is an alternative, fully-durable strategy for
Redis. It became available in version 1.1.
</p>
<p>
You can turn on the AOF in your configuration file:
</p>
<pre><code>appendonly yes
</code></pre>
<p>
From now on, every time Redis receives a command that changes the
dataset (e.g.
<a href="/commands/set">
<code>
SET
</code>
</a>
) it will append it to the AOF. When you restart
Redis it will re-play the AOF to rebuild the state.
</p>
<p>
Since Redis 7.0.0, Redis uses a multi part AOF mechanism.
That is, the original single AOF file is split into base file (at most one) and incremental files (there may be more than one).
The base file represents an initial (RDB or AOF format) snapshot of the data present when the AOF is
<a href="#log-rewriting">
rewritten
</a>
.
The incremental files contains incremental changes since the last base AOF file was created. All these files are put in a separate directory and are tracked by a manifest file.
</p>
<h3 id="log-rewriting">
Log rewriting
</h3>
<p>
The AOF gets bigger and bigger as write operations are
performed. For example, if you are incrementing a counter 100 times,
you'll end up with a single key in your dataset containing the final
value, but 100 entries in your AOF. 99 of those entries are not needed
to rebuild the current state.
</p>
<p>
The rewrite is completely safe.
While Redis continues appending to the old file,
a completely new one is produced with the minimal set of operations needed to create the current data set,
and once this second file is ready Redis switches the two and starts appending to the new one.
</p>
<p>
So Redis supports an interesting feature: it is able to rebuild the AOF
in the background without interrupting service to clients. Whenever
you issue a
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
, Redis will write the shortest sequence of
commands needed to rebuild the current dataset in memory. If you're
using the AOF with Redis 2.2 you'll need to run
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
from time to
time. Since Redis 2.4 is able to trigger log rewriting automatically (see the
example configuration file for more information).
</p>
<p>
Since Redis 7.0.0, when an AOF rewrite is scheduled, the Redis parent process opens a new incremental AOF file to continue writing.
The child process executes the rewrite logic and generates a new base AOF.
Redis will use a temporary manifest file to track the newly generated base file and incremental file.
When they are ready, Redis will perform an atomic replacement operation to make this temporary manifest file take effect.
In order to avoid the problem of creating many incremental files in case of repeated failures and retries of an AOF rewrite,
Redis introduces an AOF rewrite limiting mechanism to ensure that failed AOF rewrites are retried at a slower and slower rate.
</p>
<h3 id="how-durable-is-the-append-only-file">
How durable is the append only file?
</h3>
<p>
You can configure how many times Redis will
<a href="http://linux.die.net/man/2/fsync">
<code>
fsync
</code>
</a>
data on disk. There are
three options:
</p>
<ul>
<li>
<code>
appendfsync always
</code>
:
<code>
fsync
</code>
every time new commands are appended to the AOF. Very very slow, very safe. Note that the commands are appended to the AOF after a batch of commands from multiple clients or a pipeline are executed, so it means a single write and a single fsync (before sending the replies).
</li>
<li>
<code>
appendfsync everysec
</code>
:
<code>
fsync
</code>
every second. Fast enough (since version 2.4 likely to be as fast as snapshotting), and you may lose 1 second of data if there is a disaster.
</li>
<li>
<code>
appendfsync no
</code>
: Never
<code>
fsync
</code>
, just put your data in the hands of the Operating System. The faster and less safe method. Normally Linux will flush data every 30 seconds with this configuration, but it's up to the kernel's exact tuning.
</li>
</ul>
<p>
The suggested (and default) policy is to
<code>
fsync
</code>
every second. It is
both fast and relatively safe. The
<code>
always
</code>
policy is very slow in
practice, but it supports group commit, so if there are multiple parallel
writes Redis will try to perform a single
<code>
fsync
</code>
operation.
</p>
<h3 id="what-should-i-do-if-my-aof-gets-truncated">
What should I do if my AOF gets truncated?
</h3>
<p>
It is possible the server crashed while writing the AOF file, or the
volume where the AOF file is stored was full at the time of writing. When this happens the
AOF still contains consistent data representing a given point-in-time version
of the dataset (that may be old up to one second with the default AOF fsync
policy), but the last command in the AOF could be truncated.
The latest major versions of Redis will be able to load the AOF anyway, just
discarding the last non well formed command in the file. In this case the
server will emit a log like the following:
</p>
<pre tabindex="0"><code>* Reading RDB preamble from AOF file...
* Reading the remaining AOF tail...
# !!! Warning: short read while loading the AOF file !!!
# !!! Truncating the AOF at offset 439 !!!
# AOF loaded anyway because aof-load-truncated is enabled
</code></pre>
<p>
You can change the default configuration to force Redis to stop in such
cases if you want, but the default configuration is to continue regardless of
the fact the last command in the file is not well-formed, in order to guarantee
availability after a restart.
</p>
<p>
Older versions of Redis may not recover, and may require the following steps:
</p>
<ul>
<li>
<p>
Make a backup copy of your AOF file.
</p>
</li>
<li>
<p>
Fix the original file using the
<code>
redis-check-aof
</code>
tool that ships with Redis:
</p>
<pre><code>$ redis-check-aof --fix <filename>
</code></pre>
</li>
<li>
<p>
Optionally use
<code>
diff -u
</code>
to check what is the difference between two files.
</p>
</li>
<li>
<p>
Restart the server with the fixed file.
</p>
</li>
</ul>
<h3 id="what-should-i-do-if-my-aof-gets-corrupted">
What should I do if my AOF gets corrupted?
</h3>
<p>
If the AOF file is not just truncated, but corrupted with invalid byte
sequences in the middle, things are more complex. Redis will complain
at startup and will abort:
</p>
<pre tabindex="0"><code>* Reading the remaining AOF tail...
# Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix <filename>
</code></pre>
<p>
The best thing to do is to run the
<code>
redis-check-aof
</code>
utility, initially without
the
<code>
--fix
</code>
option, then understand the problem, jump to the given
offset in the file, and see if it is possible to manually repair the file:
The AOF uses the same format of the Redis protocol and is quite simple to fix
manually. Otherwise it is possible to let the utility fix the file for us, but
in that case all the AOF portion from the invalid part to the end of the
file may be discarded, leading to a massive amount of data loss if the
corruption happened to be in the initial part of the file.
</p>
<h3 id="how-it-works-1">
How it works
</h3>
<p>
Log rewriting uses the same copy-on-write trick already in use for
snapshotting. This is how it works:
</p>
<p>
<strong>
Redis >= 7.0
</strong>
</p>
<ul>
<li>
<p>
Redis
<a href="http://linux.die.net/man/2/fork">
forks
</a>
, so now we have a child
and a parent process.
</p>
</li>
<li>
<p>
The child starts writing the new base AOF in a temporary file.
</p>
</li>
<li>
<p>
The parent opens a new increments AOF file to continue writing updates.
If the rewriting fails, the old base and increment files (if there are any) plus this newly opened increment file represent the complete updated dataset,
so we are safe.
</p>
</li>
<li>
<p>
When the child is done rewriting the base file, the parent gets a signal,
and uses the newly opened increment file and child generated base file to build a temp manifest,
and persist it.
</p>
</li>
<li>
<p>
Profit! Now Redis does an atomic exchange of the manifest files so that the result of this AOF rewrite takes effect. Redis also cleans up the old base file and any unused increment files.
</p>
</li>
</ul>
<p>
<strong>
Redis < 7.0
</strong>
</p>
<ul>
<li>
<p>
Redis
<a href="http://linux.die.net/man/2/fork">
forks
</a>
, so now we have a child
and a parent process.
</p>
</li>
<li>
<p>
The child starts writing the new AOF in a temporary file.
</p>
</li>
<li>
<p>
The parent accumulates all the new changes in an in-memory buffer (but
at the same time it writes the new changes in the old append-only file,
so if the rewriting fails, we are safe).
</p>
</li>
<li>
<p>
When the child is done rewriting the file, the parent gets a signal,
and appends the in-memory buffer at the end of the file generated by the
child.
</p>
</li>
<li>
<p>
Now Redis atomically renames the new file into the old one,
and starts appending new data into the new file.
</p>
</li>
</ul>
<h3 id="how-i-can-switch-to-aof-if-im-currently-using-dumprdb-snapshots">
How I can switch to AOF, if I'm currently using dump.rdb snapshots?
</h3>
<p>
If you want to enable AOF in a server that is currently using RDB snapshots, you need to convert the data by enabling AOF via CONFIG command on the live server first.
</p>
<p>
<strong>
IMPORTANT:
</strong>
not following this procedure (e.g. just changing the config and restarting the server) can result in data loss!
</p>
<p>
<strong>
Redis >= 2.2
</strong>
</p>
<p>
Preparations:
</p>
<ul>
<li>
Make a backup of your latest dump.rdb file.
</li>
<li>
Transfer this backup to a safe place.
</li>
</ul>
<p>
Switch to AOF on live database:
</p>
<ul>
<li>
Enable AOF:
<code>
redis-cli config set appendonly yes
</code>
</li>
<li>
Optionally disable RDB:
<code>
redis-cli config set save ""
</code>
</li>
<li>
Make sure writes are appended to the append only file correctly.
</li>
<li>
<strong>
IMPORTANT:
</strong>
Update your
<code>
redis.conf
</code>
(potentially through
<a href="/commands/config-rewrite">
<code>
CONFIG REWRITE
</code>
</a>
) and ensure that it matches the configuration above.
If you forget this step, when you restart the server, the configuration changes will be lost and the server will start again with the old configuration, resulting in a loss of your data.
</li>
</ul>
<p>
Next time you restart the server:
</p>
<ul>
<li>
Before restarting the server, wait for AOF rewrite to finish persisting the data.
You can do that by watching
<code>
INFO persistence
</code>
, waiting for
<code>
aof_rewrite_in_progress
</code>
and
<code>
aof_rewrite_scheduled
</code>
to be
<code>
0
</code>
, and validating that
<code>
aof_last_bgrewrite_status
</code>
is
<code>
ok
</code>
.
</li>
<li>
After restarting the server, check that your database contains the same number of keys it contained previously.
</li>
</ul>
<p>
<strong>
Redis 2.0
</strong>
</p>
<ul>
<li>
Make a backup of your latest dump.rdb file.
</li>
<li>
Transfer this backup into a safe place.
</li>
<li>
Stop all the writes against the database!
</li>
<li>
Issue a
<code>
redis-cli BGREWRITEAOF
</code>
. This will create the append only file.
</li>
<li>
Stop the server when Redis finished generating the AOF dump.
</li>
<li>
Edit redis.conf end enable append only file persistence.
</li>
<li>
Restart the server.
</li>
<li>
Make sure that your database contains the same number of keys it contained before the switch.
</li>
<li>
Make sure that writes are appended to the append only file correctly.
</li>
</ul>
<h2 id="interactions-between-aof-and-rdb-persistence">
Interactions between AOF and RDB persistence
</h2>
<p>
Redis >= 2.4 makes sure to avoid triggering an AOF rewrite when an RDB
snapshotting operation is already in progress, or allowing a
<a href="/commands/bgsave">
<code>
BGSAVE
</code>
</a>
while the
AOF rewrite is in progress. This prevents two Redis background processes
from doing heavy disk I/O at the same time.
</p>
<p>
When snapshotting is in progress and the user explicitly requests a log
rewrite operation using
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
the server will reply with an OK
status code telling the user the operation is scheduled, and the rewrite
will start once the snapshotting is completed.
</p>
<p>
In the case both AOF and RDB persistence are enabled and Redis restarts the
AOF file will be used to reconstruct the original dataset since it is
guaranteed to be the most complete.
</p>
<h2 id="backing-up-redis-data">
Backing up Redis data
</h2>
<p>
Before starting this section, make sure to read the following sentence:
<strong>
Make Sure to Backup Your Database
</strong>
. Disks break, instances in the cloud disappear, and so forth: no backups means huge risk of data disappearing into /dev/null.
</p>
<p>
Redis is very data backup friendly since you can copy RDB files while the
database is running: the RDB is never modified once produced, and while it
gets produced it uses a temporary name and is renamed into its final destination
atomically using rename(2) only when the new snapshot is complete.
</p>
<p>
This means that copying the RDB file is completely safe while the server is
running. This is what we suggest:
</p>
<ul>
<li>
Create a cron job in your server creating hourly snapshots of the RDB file in one directory, and daily snapshots in a different directory.
</li>
<li>
Every time the cron script runs, make sure to call the
<code>
find
</code>
command to make sure too old snapshots are deleted: for instance you can take hourly snapshots for the latest 48 hours, and daily snapshots for one or two months. Make sure to name the snapshots with date and time information.
</li>
<li>
At least one time every day make sure to transfer an RDB snapshot
<em>
outside your data center
</em>
or at least
<em>
outside the physical machine
</em>
running your Redis instance.
</li>
</ul>
<h3 id="backing-up-aof-persistence">
Backing up AOF persistence
</h3>
<p>
If you run a Redis instance with only AOF persistence enabled, you can still perform backups.
Since Redis 7.0.0, AOF files are split into multiple files which reside in a single directory determined by the
<code>
appenddirname
</code>
configuration.
During normal operation all you need to do is copy/tar the files in this directory to achieve a backup. However, if this is done during a
<a href="#log-rewriting">
rewrite
</a>
, you might end up with an invalid backup.
To work around this you must disable AOF rewrites during the backup:
</p>
<ol>
<li>
Turn off automatic rewrites with
<br/>
<a href="/commands/config-set">
<code>
CONFIG SET
</code>
</a>
<code>
auto-aof-rewrite-percentage 0
</code>
<br/>
Make sure you don't manually start a rewrite (using
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
) during this time.
</li>
<li>
Check there's no current rewrite in progress using
<br/>
<a href="/commands/info">
<code>
INFO
</code>
</a>
<code>
persistence
</code>
<br/>
and verifying
<code>
aof_rewrite_in_progress
</code>
is 0. If it's 1, then you'll need to wait for the rewrite to complete.
</li>
<li>
Now you can safely copy the files in the
<code>
appenddirname
</code>
directory.
</li>
<li>
Re-enable rewrites when done:
<br/>
<a href="/commands/config-set">
<code>
CONFIG SET
</code>
</a>
<code>
auto-aof-rewrite-percentage <prev-value>
</code>
</li>
</ol>
<p>
<strong>
Note:
</strong>
If you want to minimize the time AOF rewrites are disabled you may create hard links to the files in
<code>
appenddirname
</code>
(in step 3 above) and then re-enable rewrites (step 4) after the hard links are created.
Now you can copy/tar the hardlinks and delete them when done. This works because Redis guarantees that it
only appends to files in this directory, or completely replaces them if necessary, so the content should be
consistent at any given point in time.
</p>
<p>
<strong>
Note:
</strong>
If you want to handle the case of the server being restarted during the backup and make sure no rewrite will automatically start after the restart you can change step 1 above to also persist the updated configuration via
<a href="/commands/config-rewrite">
<code>
CONFIG REWRITE
</code>
</a>
.
Just make sure to re-enable automatic rewrites when done (step 4) and persist it with another
<a href="/commands/config-rewrite">
<code>
CONFIG REWRITE
</code>
</a>
.
</p>
<p>
Prior to version 7.0.0 backing up the AOF file can be done simply by copying the aof file (like backing up the RDB snapshot). The file may lack the final part
but Redis will still be able to load it (see the previous sections about
<a href="#what-should-i-do-if-my-aof-gets-truncated">
truncated AOF files
</a>
).
</p>
<h2 id="disaster-recovery">
Disaster recovery
</h2>
<p>
Disaster recovery in the context of Redis is basically the same story as
backups, plus the ability to transfer those backups in many different external
data centers. This way data is secured even in the case of some catastrophic
event affecting the main data center where Redis is running and producing its
snapshots.
</p>
<p>
We'll review the most interesting disaster recovery techniques
that don't have too high costs.
</p>
<ul>
<li>
Amazon S3 and other similar services are a good way for implementing your disaster recovery system. Simply transfer your daily or hourly RDB snapshot to S3 in an encrypted form. You can encrypt your data using
<code>
gpg -c
</code>
(in symmetric encryption mode). Make sure to store your password in many different safe places (for instance give a copy to the most important people of your organization). It is recommended to use multiple storage services for improved data safety.
</li>
<li>
Transfer your snapshots using SCP (part of SSH) to far servers. This is a fairly simple and safe route: get a small VPS in a place that is very far from you, install ssh there, and generate a ssh client key without passphrase, then add it in the
<code>
authorized_keys
</code>
file of your small VPS. You are ready to transfer backups in an automated fashion. Get at least two VPS in two different providers
for best results.
</li>
</ul>
<p>
It is important to understand that this system can easily fail if not
implemented in the right way. At least, make absolutely sure that after the
transfer is completed you are able to verify the file size (that should match
the one of the file you copied) and possibly the SHA1 digest, if you are using
a VPS.
</p>
<p>
You also need some kind of independent alert system if the transfer of fresh
backups is not working for some reason.
</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/persistence/"/>
<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/ft.tagvals.html | <section class="prose w-full py-12">
<h1 class="command-name">
FT.TAGVALS
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FT.TAGVALS index field_name
</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/interact/search-and-query">
Search 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N)
</dd>
</dl>
<p>
Return a distinct set of values indexed in a Tag field
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
index
</code>
</summary>
<p>
is full-text index name. You must first create the index using
<a href="/docs/latest/commands/ft.create/">
<code>
FT.CREATE
</code>
</a>
.
</p>
</details>
<details open="">
<summary>
<code>
field_name
</code>
</summary>
<p>
is name of a Tag file defined in the schema.
</p>
</details>
<p>
Use FT.TAGVALS if your tag indexes things like cities, categories, and so on.
</p>
<h2 id="limitations">
Limitations
</h2>
<p>
FT.TAGVALS provides no paging or sorting, and the tags are not alphabetically sorted. FT.TAGVALS only operates on
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/">
tag fields
</a>
.
The returned strings are lowercase with whitespaces removed, but otherwise unchanged.
</p>
<h2 id="return">
Return
</h2>
<p>
FT.TAGVALS returns an array reply of all distinct tags in the tag index.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Return a set of values indexed in a Tag field
</b>
</summary>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> FT.TAGVALS idx myTag
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"Hello"</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"World"</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ft.create/">
<code>
FT.CREATE
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<ul>
<li>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/">
Tag fields
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/">
RediSearch
</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/ft.tagvals/"/>
<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/redisvl/api/query/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Query
</h1>
<p class="text-lg -mt-5 mb-10">
The query APIs
</p>
<h2 id="vectorquery">
VectorQuery
</h2>
<p>
<a id="query-api">
</a>
</p>
<h3 id="class-vectorqueryvector-vector_field_name-return_fieldsnone-filter_expressionnone-dtypefloat32-num_results10-return_scoretrue-dialect2">
<em>
class
</em>
VectorQuery(vector, vector_field_name, return_fields=None, filter_expression=None, dtype='float32', num_results=10, return_score=True, dialect=2)
</h3>
<p>
A query for running a vector search along with an optional filter
expression.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
vector
</strong>
(
<em>
List
</em>
*[*
<em>
float
</em>
<em>
]
</em>
) – The vector to perform the vector search with.
</li>
<li>
<strong>
vector_field_name
</strong>
(
<em>
str
</em>
) – The name of the vector field to search
against in the database.
</li>
<li>
<strong>
return_fields
</strong>
(
<em>
List
</em>
*[*
<em>
str
</em>
<em>
]
</em>
) – The declared fields to return with search
results.
</li>
<li>
<strong>
filter_expression
</strong>
(
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
<em>
,
</em>
<em>
optional
</em>
) – A filter to apply
along with the vector search. Defaults to None.
</li>
<li>
<strong>
dtype
</strong>
(
<em>
str
</em>
<em>
,
</em>
<em>
optional
</em>
) – The dtype of the vector. Defaults to
“float32”.
</li>
<li>
<strong>
num_results
</strong>
(
<em>
int
</em>
<em>
,
</em>
<em>
optional
</em>
) – The top k results to return from the
vector search. Defaults to 10.
</li>
<li>
<strong>
return_score
</strong>
(
<em>
bool
</em>
<em>
,
</em>
<em>
optional
</em>
) – Whether to return the vector
distance. Defaults to True.
</li>
<li>
<strong>
dialect
</strong>
(
<em>
int
</em>
<em>
,
</em>
<em>
optional
</em>
) – The RediSearch query dialect.
Defaults to 2.
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</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>
Learn more about vector queries in Redis:
<a href="/docs/latest/develop/interact/search-and-query/search/vectors/#knn-search">
/docs/latest/develop/interact/search-and-query/search/vectors/#knn-search
</a>
</div>
</div>
<h3 id="get_filter">
get_filter()
</h3>
<p>
Get the filter expression for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The filter for the query.
</li>
<li>
<strong>
Return type:
</strong>
<a href="filter.md#redisvl.query.filter.FilterExpression">
FilterExpression
</a>
</li>
</ul>
<h3 id="set_filterfilter_expressionnone">
set_filter(filter_expression=None)
</h3>
<p>
Set the filter expression for the query.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
filter_expression
</strong>
(
<em>
Optional
</em>
<em>
[
</em>
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The filter
to apply to the query.
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</li>
</ul>
<h3 id="set_pagingfirst-limit">
set_paging(first, limit)
</h3>
<p>
Set the paging parameters for the query to limit the number of
results.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
first
</strong>
(
<em>
int
</em>
) – The zero-indexed offset for which to fetch query results
</li>
<li>
<strong>
limit
</strong>
(
<em>
int
</em>
) – The max number of results to include including the offset
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If first or limit are NOT integers.
</li>
</ul>
<h3 id="property-params--dictstr-any">
<em>
property
</em>
params
<em>
: Dict[str, Any]
</em>
</h3>
<p>
Return the parameters for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The parameters for the query.
</li>
<li>
<strong>
Return type:
</strong>
Dict[str, Any]
</li>
</ul>
<h3 id="property-query--query">
<em>
property
</em>
query
<em>
: Query
</em>
</h3>
<p>
Return a Redis-Py Query object representing the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The Redis-Py query object.
</li>
<li>
<strong>
Return type:
</strong>
redis.commands.search.query.Query
</li>
</ul>
<h2 id="rangequery">
RangeQuery
</h2>
<h3 id="class-rangequeryvector-vector_field_name-return_fieldsnone-filter_expressionnone-dtypefloat32-distance_threshold02-num_results10-return_scoretrue-dialect2">
<em>
class
</em>
RangeQuery(vector, vector_field_name, return_fields=None, filter_expression=None, dtype='float32', distance_threshold=0.2, num_results=10, return_score=True, dialect=2)
</h3>
<p>
A query for running a filtered vector search based on semantic
distance threshold.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
vector
</strong>
(
<em>
List
</em>
*[*
<em>
float
</em>
<em>
]
</em>
) – The vector to perform the range query with.
</li>
<li>
<strong>
vector_field_name
</strong>
(
<em>
str
</em>
) – The name of the vector field to search
against in the database.
</li>
<li>
<strong>
return_fields
</strong>
(
<em>
List
</em>
*[*
<em>
str
</em>
<em>
]
</em>
) – The declared fields to return with search
results.
</li>
<li>
<strong>
filter_expression
</strong>
(
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
<em>
,
</em>
<em>
optional
</em>
) – A filter to apply
along with the range query. Defaults to None.
</li>
<li>
<strong>
dtype
</strong>
(
<em>
str
</em>
<em>
,
</em>
<em>
optional
</em>
) – The dtype of the vector. Defaults to
“float32”.
</li>
<li>
<strong>
distance_threshold
</strong>
(
<em>
str
</em>
<em>
,
</em>
<em>
float
</em>
) – The threshold for vector distance.
A smaller threshold indicates a stricter semantic search.
Defaults to 0.2.
</li>
<li>
<strong>
num_results
</strong>
(
<em>
int
</em>
) – The MAX number of results to return.
Defaults to 10.
</li>
<li>
<strong>
return_score
</strong>
(
<em>
bool
</em>
<em>
,
</em>
<em>
optional
</em>
) – Whether to return the vector
distance. Defaults to True.
</li>
<li>
<strong>
dialect
</strong>
(
<em>
int
</em>
<em>
,
</em>
<em>
optional
</em>
) – The RediSearch query dialect.
Defaults to 2.
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</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>
Learn more about vector range queries:
<a href="/docs/latest/develop/interact/search-and-query/search/vectors/#range-query">
/docs/latest/develop/interact/search-and-query/search/vectors/#range-query
</a>
</div>
</div>
<h3 id="get_filter-1">
get_filter()
</h3>
<p>
Get the filter expression for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The filter for the query.
</li>
<li>
<strong>
Return type:
</strong>
<a href="filter.md#redisvl.query.filter.FilterExpression">
FilterExpression
</a>
</li>
</ul>
<h3 id="set_distance_thresholddistance_threshold">
set_distance_threshold(distance_threshold)
</h3>
<p>
Set the distance treshold for the query.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
distance_threshold
</strong>
(
<em>
float
</em>
) – vector distance
</li>
</ul>
<h3 id="set_filterfilter_expressionnone-1">
set_filter(filter_expression=None)
</h3>
<p>
Set the filter expression for the query.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
filter_expression
</strong>
(
<em>
Optional
</em>
<em>
[
</em>
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The filter
to apply to the query.
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</li>
</ul>
<h3 id="set_pagingfirst-limit-1">
set_paging(first, limit)
</h3>
<p>
Set the paging parameters for the query to limit the number of
results.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
first
</strong>
(
<em>
int
</em>
) – The zero-indexed offset for which to fetch query results
</li>
<li>
<strong>
limit
</strong>
(
<em>
int
</em>
) – The max number of results to include including the offset
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If first or limit are NOT integers.
</li>
</ul>
<h3 id="property-distance_threshold--float">
<em>
property
</em>
distance_threshold
<em>
: float
</em>
</h3>
<p>
Return the distance threshold for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The distance threshold for the query.
</li>
<li>
<strong>
Return type:
</strong>
float
</li>
</ul>
<h3 id="property-params--dictstr-any-1">
<em>
property
</em>
params
<em>
: Dict[str, Any]
</em>
</h3>
<p>
Return the parameters for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The parameters for the query.
</li>
<li>
<strong>
Return type:
</strong>
Dict[str, Any]
</li>
</ul>
<h3 id="property-query--query-1">
<em>
property
</em>
query
<em>
: Query
</em>
</h3>
<p>
Return a Redis-Py Query object representing the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The Redis-Py query object.
</li>
<li>
<strong>
Return type:
</strong>
redis.commands.search.query.Query
</li>
</ul>
<h2 id="filterquery">
FilterQuery
</h2>
<h3 id="class-filterqueryfilter_expression-return_fieldsnone-num_results10-dialect2-paramsnone">
<em>
class
</em>
FilterQuery(filter_expression, return_fields=None, num_results=10, dialect=2, params=None)
</h3>
<p>
A query for a running a filtered search with a filter expression.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
filter_expression
</strong>
(
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
) – The filter expression to
query for.
</li>
<li>
<strong>
return_fields
</strong>
(
<em>
Optional
</em>
*[*
<em>
List
</em>
*[*
<em>
str
</em>
<em>
]
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The fields to return.
</li>
<li>
<strong>
num_results
</strong>
(
<em>
Optional
</em>
*[*
<em>
int
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The number of results to
return. Defaults to 10.
</li>
<li>
<strong>
params
</strong>
(
<em>
Optional
</em>
*[*
<em>
Dict
</em>
*[*
<em>
str
</em>
<em>
,
</em>
<em>
Any
</em>
<em>
]
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The parameters for the
query. Defaults to None.
</li>
<li>
<strong>
dialect
</strong>
(
<em>
int
</em>
) –
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query</span> <span class="kn">import</span> <span class="n">FilterQuery</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query.filter</span> <span class="kn">import</span> <span class="n">Tag</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"brand"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"Nike"</span>
</span></span><span class="line"><span class="cl"><span class="n">q</span> <span class="o">=</span> <span class="n">FilterQuery</span><span class="p">(</span><span class="n">return_fields</span><span class="o">=</span><span class="p">[</span><span class="s2">"brand"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">],</span> <span class="n">filter_expression</span><span class="o">=</span><span class="n">t</span><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="get_filter-2">
get_filter()
</h3>
<p>
Get the filter expression for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The filter for the query.
</li>
<li>
<strong>
Return type:
</strong>
<a href="filter.md#redisvl.query.filter.FilterExpression">
FilterExpression
</a>
</li>
</ul>
<h3 id="set_filterfilter_expressionnone-2">
set_filter(filter_expression=None)
</h3>
<p>
Set the filter expression for the query.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
filter_expression
</strong>
(
<em>
Optional
</em>
<em>
[
</em>
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The filter
to apply to the query.
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</li>
</ul>
<h3 id="set_pagingfirst-limit-2">
set_paging(first, limit)
</h3>
<p>
Set the paging parameters for the query to limit the number of
results.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
first
</strong>
(
<em>
int
</em>
) – The zero-indexed offset for which to fetch query results
</li>
<li>
<strong>
limit
</strong>
(
<em>
int
</em>
) – The max number of results to include including the offset
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If first or limit are NOT integers.
</li>
</ul>
<h3 id="property-query--query-2">
<em>
property
</em>
query
<em>
: Query
</em>
</h3>
<p>
Return a Redis-Py Query object representing the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The Redis-Py query object.
</li>
<li>
<strong>
Return type:
</strong>
redis.commands.search.query.Query
</li>
</ul>
<h2 id="countquery">
CountQuery
</h2>
<h3 id="class-countqueryfilter_expression-dialect2-paramsnone">
<em>
class
</em>
CountQuery(filter_expression, dialect=2, params=None)
</h3>
<p>
A query for a simple count operation provided some filter expression.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
filter_expression
</strong>
(
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
) – The filter expression to query for.
</li>
<li>
<strong>
params
</strong>
(
<em>
Optional
</em>
*[*
<em>
Dict
</em>
*[*
<em>
str
</em>
<em>
,
</em>
<em>
Any
</em>
<em>
]
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The parameters for the query. Defaults to None.
</li>
<li>
<strong>
dialect
</strong>
(
<em>
int
</em>
) –
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query</span> <span class="kn">import</span> <span class="n">CountQuery</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query.filter</span> <span class="kn">import</span> <span class="n">Tag</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"brand"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"Nike"</span>
</span></span><span class="line"><span class="cl"><span class="n">query</span> <span class="o">=</span> <span class="n">CountQuery</span><span class="p">(</span><span class="n">filter_expression</span><span class="o">=</span><span class="n">t</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">count</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">query</span><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="get_filter-3">
get_filter()
</h3>
<p>
Get the filter expression for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The filter for the query.
</li>
<li>
<strong>
Return type:
</strong>
<a href="filter.md#redisvl.query.filter.FilterExpression">
FilterExpression
</a>
</li>
</ul>
<h3 id="set_filterfilter_expressionnone-3">
set_filter(filter_expression=None)
</h3>
<p>
Set the filter expression for the query.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
filter_expression
</strong>
(
<em>
Optional
</em>
<em>
[
</em>
<a href="filter.md#redisvl.query.filter.FilterExpression">
<em>
FilterExpression
</em>
</a>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) – The filter
to apply to the query.
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If filter_expression is not of type redisvl.query.FilterExpression
</li>
</ul>
<h3 id="set_pagingfirst-limit-3">
set_paging(first, limit)
</h3>
<p>
Set the paging parameters for the query to limit the number of
results.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
first
</strong>
(
<em>
int
</em>
) – The zero-indexed offset for which to fetch query results
</li>
<li>
<strong>
limit
</strong>
(
<em>
int
</em>
) – The max number of results to include including the offset
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<strong>
TypeError
</strong>
– If first or limit are NOT integers.
</li>
</ul>
<h3 id="property-params--dictstr-any-2">
<em>
property
</em>
params
<em>
: Dict[str, Any]
</em>
</h3>
<p>
The parameters for the query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The parameters for the query.
</li>
<li>
<strong>
Return type:
</strong>
Dict[str, Any]
</li>
</ul>
<h3 id="property-query--query-3">
<em>
property
</em>
query
<em>
: Query
</em>
</h3>
<p>
The loaded Redis-Py query.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The Redis-Py query object.
</li>
<li>
<strong>
Return type:
</strong>
redis.commands.search.query.Query
</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/integrate/redisvl/api/query/"/>
<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/cms.incrby/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CMS.INCRBY
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CMS.INCRBY key item increment [item increment ...]</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.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(n) where n is the number of items
</dd>
</dl>
<p>
Increases the count of item by increment. Multiple items can be increased with one call.
</p>
<h3 id="parameters">
Parameters:
</h3>
<ul>
<li>
<strong>
key
</strong>
: The name of the sketch.
</li>
<li>
<strong>
item
</strong>
: The item which counter is to be increased.
</li>
<li>
<strong>
increment
</strong>
: Amount by which the item counter is to be increased.
</li>
</ul>
<h2 id="return">
Return
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
of
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
with an updated min-count of each of the items in the sketch.
</p>
<p>
Count of each item after increment.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>redis> CMS.INCRBY test foo 10 bar 42
1) (integer) 10
2) (integer) 42
</code></pre>
<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/cms.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/operate/rs/7.4/security/encryption/tls/enable-tls/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Enable TLS
</h1>
<p class="text-lg -mt-5 mb-10">
Shows how to enable TLS.
</p>
<p>
You can use TLS authentication for one or more of the following types of communication:
</p>
<ul>
<li>
Communication from clients (applications) to your database
</li>
<li>
Communication from your database to other clusters for replication using
<a href="/docs/latest/operate/rs/7.4/databases/import-export/replica-of/">
Replica Of
</a>
</li>
<li>
Communication to and from your database to other clusters for synchronization using
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
Active-Active
</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>
When you enable or turn off TLS, the change applies to new connections but does not affect existing connections. Clients must close existing connections and reconnect to apply the change.
</div>
</div>
<h2 id="client">
Enable TLS for client connections
</h2>
<p>
To enable TLS for client connections:
</p>
<ol>
<li>
<p>
From your database's
<strong>
Security
</strong>
tab, select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
TLS - Transport Layer Security for secure connections
</strong>
section, make sure the checkbox is selected.
</p>
</li>
<li>
<p>
In the
<strong>
Apply TLS for
</strong>
section, select
<strong>
Clients and databases + Between databases
</strong>
.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<p>
To enable mutual TLS for client connections:
</p>
<ol>
<li>
<p>
Select
<strong>
Mutual TLS (Client authentication)
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-mtls-clients.png" sdata-lightbox="/images/rs/screenshots/databases/security-mtls-clients.png">
<img alt="Mutual TLS authentication configuration." src="/docs/latest/images/rs/screenshots/databases/security-mtls-clients.png"/>
</a>
</li>
<li>
<p>
For each client certificate, select
<strong>
+ Add certificate
</strong>
, paste or upload the client certificate, then select
<strong>
Done
</strong>
.
</p>
<p>
If your database uses Replica Of or Active-Active replication, you also need to add the syncer certificates for the participating clusters. See
<a href="#enable-tls-for-replica-of-cluster-connections">
Enable TLS for Replica Of cluster connections
</a>
or
<a href="#enable-tls-for-active-active-cluster-connections">
Enable TLS for Active-Active cluster connections
</a>
for instructions.
</p>
</li>
<li>
<p>
You can configure
<strong>
Additional certificate validations
</strong>
to further limit connections to clients with valid certificates.
</p>
<p>
Additional certificate validations occur only when loading a
<a href="https://en.wikipedia.org/wiki/Chain_of_trust#Computer_security">
certificate chain
</a>
that includes the
<a href="https://en.wikipedia.org/wiki/Root_certificate">
root certificate
</a>
and intermediate
<a href="https://en.wikipedia.org/wiki/Certificate_authority">
CA
</a>
certificate but does not include a leaf (end-entity) certificate. If you include a leaf certificate, mutual client authentication skips any additional certificate validations.
</p>
<ol>
<li>
<p>
Select a certificate validation option.
</p>
<table>
<thead>
<tr>
<th>
Validation option
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<em>
No validation
</em>
</td>
<td>
Authenticates clients with valid certificates. No additional validations are enforced.
</td>
</tr>
<tr>
<td>
<em>
By Subject Alternative Name
</em>
</td>
<td>
A client certificate is valid only if its Common Name (CN) matches an entry in the list of valid subjects. Ignores other
<a href="https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6">
<code>
Subject
</code>
</a>
attributes.
</td>
</tr>
<tr>
<td>
<em>
By full Subject Name
</em>
</td>
<td>
A client certificate is valid only if its
<a href="https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6">
<code>
Subject
</code>
</a>
attributes match an entry in the list of valid subjects.
</td>
</tr>
</tbody>
</table>
</li>
<li>
<p>
If you selected
<strong>
No validation
</strong>
, you can skip this step. Otherwise, select
<strong>
+ Add validation
</strong>
to create a new entry and then enter valid
<a href="https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6">
<code>
Subject
</code>
</a>
attributes for your client certificates. All
<code>
Subject
</code>
attributes are case-sensitive.
</p>
<table>
<thead>
<tr>
<th>
Subject attribute
<br/>
(case-sensitive)
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<em>
Common Name (CN)
</em>
</td>
<td>
Name of the client authenticated by the certificate (
<em>
required
</em>
)
</td>
</tr>
<tr>
<td>
<em>
Organization (O)
</em>
</td>
<td>
The client's organization or company name
</td>
</tr>
<tr>
<td>
<nobr>
<em>
Organizational Unit (OU)
</em>
</nobr>
</td>
<td>
Name of the unit or department within the organization
</td>
</tr>
<tr>
<td>
<em>
Locality (L)
</em>
</td>
<td>
The organization's city
</td>
</tr>
<tr>
<td>
<em>
State / Province (ST)
</em>
</td>
<td>
The organization's state or province
</td>
</tr>
<tr>
<td>
<em>
Country (C)
</em>
</td>
<td>
2-letter code that represents the organization's country
</td>
</tr>
</tbody>
</table>
<p>
You can only enter a single value for each field, except for the
<em>
Organizational Unit (OU)
</em>
field. If your client certificate has a
<code>
Subject
</code>
with multiple
<em>
Organizational Unit (OU)
</em>
values, press the
<code>
Enter
</code>
or
<code>
Return
</code>
key after entering each value to add multiple Organizational Units.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-mtls-add-cert-validation-multi-ou.png" sdata-lightbox="/images/rs/screenshots/databases/security-mtls-add-cert-validation-multi-ou.png">
<img alt="An example that shows adding a certificate validation with multiple organizational units." src="/docs/latest/images/rs/screenshots/databases/security-mtls-add-cert-validation-multi-ou.png" width="350px"/>
</a>
<p>
<strong>
Breaking change:
</strong>
If you use the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
instead of the Cluster Manager UI to configure additional certificate validations, note that
<code>
authorized_names
</code>
is deprecated as of Redis Enterprise v6.4.2. Use
<code>
authorized_subjects
</code>
instead. See the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/bdb/">
BDB object reference
</a>
for more details.
</p>
</li>
</ol>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</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>
<p>
By default, Redis Enterprise Software validates client certificate expiration dates. You can use
<code>
rladmin
</code>
to turn off this behavior.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune db < db:id <span class="p">|</span> name > mtls_allow_outdated_certs enabled
</span></span></code></pre>
</div>
</div>
</div>
</li>
</ol>
<h2 id="enable-tls-for-active-active-cluster-connections">
Enable TLS for Active-Active cluster connections
</h2>
<p>
To enable TLS for Active-Active cluster connections:
</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>
<a href="#retrieve-syncer-certificates">
Retrieve syncer certificates.
</a>
</p>
</li>
<li>
<p>
<a href="#configure-tls-certificates-for-active-active">
Configure TLS certificates for Active-Active.
</a>
</p>
</li>
<li>
<p>
<a href="#configure-tls-on-all-participating-clusters">
Configure TLS on all participating clusters.
</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>
You cannot enable or turn off TLS after the Active-Active database is created, but you can change the TLS configuration.
</div>
</div>
<h3 id="retrieve-syncer-certificates">
Retrieve syncer certificates
</h3>
<p>
For each participating cluster, copy the syncer certificate from the
<strong>
general
</strong>
settings tab.
</p>
<a href="/docs/latest/images/rs/general-settings-syncer-cert.png" sdata-lightbox="/images/rs/general-settings-syncer-cert.png">
<img alt="general-settings-syncer-cert" src="/docs/latest/images/rs/general-settings-syncer-cert.png"/>
</a>
<h3 id="configure-tls-certificates-for-active-active">
Configure TLS certificates for Active-Active
</h3>
<ol>
<li>
During database creation (see
<a href="/docs/latest/operate/rs/7.4/databases/active-active/create/">
Create an Active-Active Geo-Replicated Database
</a>
, select
<strong>
Edit
</strong>
from the
<strong>
configuration
</strong>
tab.
</li>
<li>
Enable
<strong>
TLS
</strong>
.
<ul>
<li>
<strong>
Enforce client authentication
</strong>
is selected by default. If you clear this option, you will still enforce encryption, but TLS client authentication will be deactivated.
</li>
</ul>
</li>
<li>
Select
<strong>
Require TLS for CRDB communication only
</strong>
from the dropdown menu.
<a href="/docs/latest/images/rs/crdb-tls-all.png" sdata-lightbox="/images/rs/crdb-tls-all.png">
<img alt="crdb-tls-all" src="/docs/latest/images/rs/crdb-tls-all.png"/>
</a>
</li>
<li>
Select
<strong>
Add
</strong>
<a href="/docs/latest/images/rs/icon_add.png#no-click" sdata-lightbox="/images/rs/icon_add.png#no-click">
<img alt="Add" src="/docs/latest/images/rs/icon_add.png#no-click"/>
</a>
</li>
<li>
Paste a syncer certificate into the text box.
<a href="/docs/latest/images/rs/database-tls-replica-certs.png" sdata-lightbox="/images/rs/database-tls-replica-certs.png">
<img alt="Database TLS Configuration" src="/docs/latest/images/rs/database-tls-replica-certs.png"/>
</a>
</li>
<li>
Save the syncer certificate.
<a href="/docs/latest/images/rs/icon_save.png#no-click" sdata-lightbox="/images/rs/icon_save.png#no-click">
<img alt="Save" src="/docs/latest/images/rs/icon_save.png#no-click"/>
</a>
</li>
<li>
Repeat this process, adding the syncer certificate for each participating cluster.
</li>
<li>
Optional: If also you want to require TLS for client connections, select
<strong>
Require TLS for All Communications
</strong>
from the dropdown and add client certificates as well.
</li>
<li>
Select
<strong>
Update
</strong>
at the bottom of the screen to save your configuration.
</li>
</ol>
<h3 id="configure-tls-on-all-participating-clusters">
Configure TLS on all participating clusters
</h3>
<p>
Repeat this process on all participating clusters.
</p>
<p>
To enforce TLS authentication, Active-Active databases require syncer certificates for each cluster connection. If every participating cluster doesn't have a syncer certificate for every other participating cluster, synchronization will fail.
</p>
<h2 id="enable-tls-for-replica-of-cluster-connections">
Enable TLS for Replica Of cluster connections
</h2>
<p>
To enable TLS for Replica Of cluster connections:
</p>
<ol>
<li>
<p>
For each cluster hosting a replica:
</p>
<ol>
<li>
<p>
Go to
<strong>
Cluster > Security > Certificates
</strong>
.
</p>
</li>
<li>
<p>
Expand the
<strong>
Replica Of and Active-Active authentication (Syncer certificate)
</strong>
section.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/security-syncer-cert.png" sdata-lightbox="/images/rs/screenshots/cluster/security-syncer-cert.png">
<img alt="Syncer certificate for Replica Of and Active-Active authentication." src="/docs/latest/images/rs/screenshots/cluster/security-syncer-cert.png"/>
</a>
</li>
<li>
<p>
Download or copy the syncer certificate.
</p>
</li>
</ol>
</li>
<li>
<p>
From the
<strong>
Security
</strong>
tab of the Replica Of source database, select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
TLS - Transport Layer Security for secure connections
</strong>
section, make sure the checkbox is selected.
</p>
</li>
<li>
<p>
In the
<strong>
Apply TLS for
</strong>
section, select
<strong>
Between databases only
</strong>
.
</p>
</li>
<li>
<p>
Select
<strong>
Mutual TLS (Client authentication)
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-tls-replica-of.png" sdata-lightbox="/images/rs/screenshots/databases/security-tls-replica-of.png">
<img alt="Replica Of TLS authentication configuration." src="/docs/latest/images/rs/screenshots/databases/security-tls-replica-of.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
+ Add certificate
</strong>
, paste or upload the syncer certificate, then select
<strong>
Done
</strong>
.
</p>
<p>
Repeat this process, adding the syncer certificate for each cluster hosting a replica of this database.
</p>
</li>
<li>
<p>
<em>
(Optional)
</em>
To require TLS for client connections, change
<strong>
Apply TLS for
</strong>
to
<strong>
Clients and databases + Between databases
</strong>
and add client certificates.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</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/7.4/security/encryption/tls/enable-tls/"/>
<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/crdb/cluster_info/.html | <section class="prose w-full py-12 max-w-none">
<h1>
CRDB cluster info object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents Active-Active cluster info
</p>
<p>
Configuration details for a cluster that is part of an Active-Active database.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
credentials
</td>
<td>
<pre><code>
{
"username": string,
"password": string
} </code></pre>
</td>
<td>
Cluster access credentials (required)
</td>
</tr>
<tr>
<td>
name
</td>
<td>
string
</td>
<td>
Cluster fully qualified name, used to uniquely identify the cluster. Typically this is the same as the hostname used in the URL, although in some configruations the URL may point to a different name/address. (required)
</td>
</tr>
<tr>
<td>
replication_endpoint
</td>
<td>
string
</td>
<td>
Address to use for peer replication. If not specified, it is assumed that standard cluster naming conventions apply.
</td>
</tr>
<tr>
<td>
replication_tls_sni
</td>
<td>
string
</td>
<td>
Cluster SNI for TLS connections
</td>
</tr>
<tr>
<td>
url
</td>
<td>
string
</td>
<td>
Cluster access URL (required)
</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/crdb/cluster_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/operate/rs/7.4/databases/memory-performance/memory-limit/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Database memory limits
</h1>
<p class="text-lg -mt-5 mb-10">
When you set a database's memory limit, you define the maximum size the database can reach.
</p>
<p>
When you set a database's memory limit, you define the maximum size the
database can reach in the cluster, across all database replicas and
shards, including both primary and replica shards.
</p>
<p>
If the total size of the database in the cluster reaches the memory
limit, the data eviction policy is
applied.
</p>
<h2 id="factors-for-sizing">
Factors for sizing
</h2>
<p>
Factors to consider when sizing your database:
</p>
<ul>
<li>
<strong>
dataset size
</strong>
: you want your limit to be above your dataset size to leave room for overhead.
</li>
<li>
<strong>
database throughput
</strong>
: high throughput needs more shards, leading to a higher memory limit.
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/">
<strong>
modules
</strong>
</a>
: using modules with your database consumes more memory.
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/clustering/">
<strong>
database clustering
</strong>
</a>
: enables you to spread your data into shards across multiple nodes.
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/replication/">
<strong>
database replication
</strong>
</a>
: enabling replication doubles memory consumption.
</li>
</ul>
<p>
Additional factors for Active-Active databases:
</p>
<ul>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
<strong>
Active-Active replication
</strong>
</a>
: enabling Active-Active replication requires double the memory of regular replication, which can be up to two times (2x) the original data size per instance.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/manage/#replication-backlog/">
<strong>
database replication backlog
</strong>
</a>
for synchronization between shards. By default, this is set to 1% of the database size.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/manage/">
<strong>
Active-Active replication backlog
</strong>
</a>
for synchronization between clusters. By default, this is set to 1% of the database size.
</p>
<p>
It's also important to know Active-Active databases have a lower threshold for activating the eviction policy, because it requires propagation to all participating clusters. The eviction policy starts to evict keys when one of the Active-Active instances reaches 80% of its memory limit.
</p>
</li>
</ul>
<p>
Additional factors for databases with Auto Tiering enabled:
</p>
<ul>
<li>
<p>
The available flash space must be greater than or equal to the total database size (RAM+Flash). The extra space accounts for write buffers and
<a href="https://en.wikipedia.org/wiki/Write_amplification">
write amplification
</a>
.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/configure/database-persistence/">
<strong>
database persistence
</strong>
</a>
: Auto Tiering uses dual database persistence where both the primary and replica shards persist to disk. This may add some processor and network overhead, especially in cloud configurations with network attached storage.
</p>
</li>
</ul>
<h2 id="what-happens-when-redis-enterprise-software-is-low-on-ram">
What happens when Redis Enterprise Software is low on RAM?
</h2>
<p>
Redis Enterprise Software manages node memory so that data is entirely in RAM (unless using Auto Tiering). If not enough RAM is available, Redis Enterprise prevents adding more data into the databases.
</p>
<p>
Redis Enterprise Software protects the existing data and prevents the database from being able to store data into the shards.
</p>
<p>
You can configure the cluster to move the data to another node, or even discard it according to the
<a href="/docs/latest/operate/rs/7.4/databases/memory-performance/eviction-policy/">
eviction policy
</a>
set on each database by the administrator.
</p>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/auto-tiering/">
Auto Tiering
</a>
manages memory so that you can also use flash memory (SSD) to store data.
</p>
<h3 id="order-of-events-for-low-ram">
Order of events for low RAM
</h3>
<ol>
<li>
If there are other nodes available, your shards migrate to other nodes.
</li>
<li>
If the eviction policy allows eviction, shards start to release memory,
which can result in data loss.
</li>
<li>
If the eviction policy does not allow eviction, you'll receive
out of memory (OOM) messages.
</li>
<li>
If shards can't free memory, Redis Enterprise relies on the OS processes to stop replicas,
but tries to avoid stopping primary shards.
</li>
</ol>
<p>
We recommend that you have a
<a href="/docs/latest/operate/rs/7.4/clusters/monitoring/">
monitoring platform
</a>
that alerts you before a system gets low on RAM.
You must maintain sufficient free memory to make sure that you have a healthy Redis Enterprise installation.
</p>
<h2 id="memory-metrics">
Memory metrics
</h2>
<p>
The Cluster Manager UI provides metrics that can help you evaluate your memory use.
</p>
<ul>
<li>
Free RAM
</li>
<li>
RAM fragmentation
</li>
<li>
Used memory
</li>
<li>
Memory usage
</li>
<li>
Memory limit
</li>
</ul>
<p>
See
<a href="/docs/latest/operate/rs/7.4/references/metrics/">
console metrics
</a>
for more detailed information.
</p>
<h2 id="related-info">
Related info
</h2>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/memory-performance/">
Memory and performance
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/clusters/optimize/disk-sizing-heavy-write-scenarios/">
Disk sizing for heavy write scenarios
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/clusters/optimize/turn-off-services/">
Turn off services to free system memory
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/memory-performance/eviction-policy/">
Eviction policy
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/memory-performance/shard-placement-policy/">
Shard placement policy
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/configure/database-persistence/">
Database persistence
</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/operate/rs/7.4/databases/memory-performance/memory-limit/"/>
<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/crdt_sources-alerts/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Database CRDT sources alerts requests
</h1>
<p class="text-lg -mt-5 mb-10">
Conflict-free replicated data type (CRDT) source alert requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-bdbs-crdt-sources-alerts">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/crdt_sources/alerts
</code>
</td>
<td>
Get all CRDT sources alert states for all CRDB databases
</td>
</tr>
<tr>
<td>
<a href="#get-bdbs-crdt-sources-alerts">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/crdt_sources/alerts/{uid}
</code>
</td>
<td>
Get all CRDT sources alert states for a database
</td>
</tr>
<tr>
<td>
<a href="#get-bdbs-crdt-source-all-alerts">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/crdt_sources/alerts/{uid}/{crdt_src_id}
</code>
</td>
<td>
Get all alert states for a CRDT source
</td>
</tr>
<tr>
<td>
<a href="#get-bdbs-crdt-source-alert">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/crdt_sources/alerts/{uid}/{crdt_src_id}/{alert}
</code>
</td>
<td>
Get a database alert state
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-bdbs-crdt-sources-alerts">
Get all CRDB CRDT source alert states
</h2>
<pre><code>GET /v1/bdbs/crdt_sources/alerts
</code></pre>
<p>
Get all alert states for all CRDT sources of all CRDBs.
</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/#view_all_bdbs_alerts">
view_all_bdbs_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /bdbs/crdt_sources/alerts
</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-all-response">
Response
</h3>
<p>
Returns a hash of alert UIDs and the
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alerts states
</a>
for each local BDB of CRDB.
</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">"1"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"crdt_src_syncer_connection_error"</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">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-08-29T11:19:49Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"memory_util"</span><span class="p">:</span> <span class="mf">81.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><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-all-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="get-bdbs-crdt-sources-alerts">
Get all BDB CRDT sources alert states
</h2>
<pre><code>GET /v1/bdbs/crdt_sources/alerts/{int: uid}
</code></pre>
<p>
Get all alert states for all crdt sources for a specific local bdb of a CRDB.
</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/references/rest-api/permissions/#view_bdb_alerts">
view_bdb_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request-all-crdt-alerts">
Request
</h3>
<h4 id="example-http-request-1">
Example HTTP request
</h4>
<pre><code>GET /bdbs/crdt_sources/alerts/1
</code></pre>
<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>
uid
</td>
<td>
integer
</td>
<td>
The unique ID of the database
</td>
</tr>
</tbody>
</table>
<h3 id="get-response-all-crdt-alerts">
Response
</h3>
<p>
Returns a hash of
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alert objects
</a>
and their states.
</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">"crdt_src_syncer_connection_error"</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">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-08-29T11:19:49Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"memory_util"</span><span class="p">:</span> <span class="mf">81.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><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes-all-crdt-alerts">
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.5">
404 Not Found
</a>
</td>
<td>
Specified bdb does not exist
</td>
</tr>
</tbody>
</table>
<h2 id="get-bdbs-crdt-source-all-alerts">
Get all CRDT source alert states
</h2>
<pre><code>GET /v1/bdbs/crdt_sources/alerts/{int: uid}/{int: crdt_src_id}
</code></pre>
<p>
Get all alert states for specific crdt source for a specific local BDB
of a CRDB.
</p>
<h4 id="required-permissions-2">
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/#view_bdb_alerts">
view_bdb_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request-crdt-alerts">
Request
</h3>
<h4 id="example-http-request-2">
Example HTTP request
</h4>
<pre><code>GET /bdbs/crdt_sources/alerts/1/2
</code></pre>
<h4 id="request-headers-2">
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-1">
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>
<tr>
<td>
crdt_src_id
</td>
<td>
integer
</td>
<td>
The ID of the crdt source in this BDB
</td>
</tr>
</tbody>
</table>
<h3 id="get-response-crdt-alerts">
Response
</h3>
<p>
Returns a hash of
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alert objects
</a>
and their states.
</p>
<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">"crdt_src_syncer_connection_error"</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">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-08-29T11:19:49Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"memory_util"</span><span class="p">:</span> <span class="mf">81.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><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes-crdt-alerts">
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.5">
404 Not Found
</a>
</td>
<td>
Specified bdb does not exist
</td>
</tr>
</tbody>
</table>
<h2 id="get-bdbs-crdt-source-alert">
Get database alert state
</h2>
<pre><code>GET /v1/bdbs/crdt_sources/alerts/{int: uid}/{int: crdt_src_id}/{alert}
</code></pre>
<p>
Get a BDB alert state.
</p>
<h4 id="required-permissions-3">
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/#view_bdb_alerts">
view_bdb_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request-alert">
Request
</h3>
<h4 id="example-http-request-3">
Example HTTP request
</h4>
<pre><code>GET /bdbs/crdt_sources/alerts/1/2/crdt_src_syncer_connection_error
</code></pre>
<h4 id="request-headers-3">
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-2">
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>
<tr>
<td>
crdt_src_id
</td>
<td>
integer
</td>
<td>
The ID of the crdt source in this BDB
</td>
</tr>
<tr>
<td>
alert
</td>
<td>
string
</td>
<td>
The alert name
</td>
</tr>
</tbody>
</table>
<h3 id="get-response-alert">
Response
</h3>
<p>
Returns an
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alert object
</a>
.
</p>
<h4 id="example-json-body-3">
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">"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">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-08-29T11:19:49Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</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 class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"memory_util"</span><span class="p">:</span> <span class="mf">81.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-alert">
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 request
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
Specified alert or bdb does not exist
</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/crdt_sources-alerts/"/>
<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/programmability/triggers-and-functions/concepts/javascript_api/.html | <section class="prose w-full py-12 max-w-none">
<h1>
JavaScript API
</h1>
<p class="text-lg -mt-5 mb-10">
Overview of the JavaScript API
</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>
<h2 id="redis-object">
Redis object
</h2>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
The triggers and functions JavaScript API provides a singleton instance of an object named
<em>
redis
</em>
. The
<em>
redis
</em>
instance enables registered functions to interact with the Redis server on which they are running. Following is the API provided by the
<em>
redis
</em>
instance.
</p>
<h3 id="redisregisterfunction">
<code>
redis.registerFunction
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Register a new function that can later be invoke using
<code>
TFCALL
</code>
command.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="c1">//name and callback mandatory
</span></span></span><span class="line"><span class="cl"><span class="c1">//object with optional arguments
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nx">redis</span><span class="p">.</span><span class="nx">registerFunction</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">//name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">args</span><span class="p">)</span> <span class="p">{},</span> <span class="c1">//callback
</span></span></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="nx">description</span><span class="o">:</span> <span class="s1">'The description'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">flags</span><span class="o">:</span> <span class="p">[</span><span class="nx">redis</span><span class="p">.</span><span class="nx">functionFlags</span><span class="p">.</span><span class="nx">NO_WRITES</span><span class="p">,</span> <span class="nx">redis</span><span class="p">.</span><span class="nx">functionFlags</span><span class="p">.</span><span class="nx">ALLOW_OOM</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span> <span class="c1">// optional arguments
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">);</span>
</span></span></code></pre>
</div>
<h3 id="redisregisterasyncfunction">
<code>
redis.registerAsyncFunction
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Register a new async function that can later be invoke using
<code>
TFCALLASYNC
</code>
command.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerAsyncFunction</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">//Function name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">args</span><span class="p">){},</span> <span class="c1">//callback
</span></span></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="nx">description</span><span class="o">:</span> <span class="s1">'description'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">flags</span><span class="o">:</span> <span class="p">[</span><span class="nx">redis</span><span class="p">.</span><span class="nx">functionFlags</span><span class="p">.</span><span class="nx">NO_WRITES</span><span class="p">,</span> <span class="nx">redis</span><span class="p">.</span><span class="nx">functionFlags</span><span class="p">.</span><span class="nx">ALLOW_OOM</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span> <span class="c1">//optional arguments
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">);</span>
</span></span></code></pre>
</div>
<h3 id="redisregisterkeyspacetrigger">
<code>
redis.registerKeySpaceTrigger
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Register a key space notification trigger that will run whenever a key space notification fired.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerKeySpaceTrigger</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">// trigger name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="s1">'keys:*'</span><span class="p">,</span> <span class="c1">//key prefix
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{},</span> <span class="c1">//callback
</span></span></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="nx">description</span><span class="o">:</span> <span class="s1">'description'</span>
</span></span><span class="line"><span class="cl"> <span class="nx">onTriggerFired</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">){}</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span> <span class="c1">//optional arguments
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="redisregisterstreamtrigger">
<code>
redis.registerStreamTrigger
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Register a stream trigger that will be invoke whenever a data is added to a stream.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerStreamTrigger</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">//trigger name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="s1">'stream:*'</span><span class="p">,</span> <span class="c1">//prefix
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">){},</span><span class="c1">//callback
</span></span></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="nx">description</span><span class="o">:</span> <span class="s1">'Description'</span>
</span></span><span class="line"><span class="cl"> <span class="nb">window</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">isStreamTrimmed</span><span class="o">:</span> <span class="kc">false</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span> <span class="c1">//optional arguments
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="redisregisterclusterfunction">
<code>
redis.registerClusterFunction
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Register a cluster function that can later be called using
<code>
async_client.runOnKey()
</code>
or
<code>
async_client.runOnShards()
</code>
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerClusterFunction</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">//name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="kr">async</span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="p">...</span><span class="nx">args</span><span class="p">){}</span> <span class="c1">//callback
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="redisconfig">
<code>
redis.config
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-Shell" data-lang="Shell"><span class="line"><span class="cl">redis-cli -x RG.FUNCTION LOAD UPGRADE CONFIG <span class="s1">'{"example_config": "example_config_value"}'</span> < main.js
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">configExample</span> <span class="o">=</span> <span class="nx">redis</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">example_config</span><span class="p">;</span>
</span></span></code></pre>
</div>
<h2 id="client-object">
Client object
</h2>
<p>
Client object that is used to perform operations on Redis.
</p>
<h3 id="clientcall">
<code>
client.call
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Run a command on Redis. The command is executed on the current Redis instrance.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">''</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">...</span><span class="nx">args</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="clientcallraw">
<code>
client.callRaw
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Run a command on Redis but does not perform UTF8 decoding on the result. The command is executed on the current Redis instrance.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">callRaw</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">''</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">...</span><span class="nx">args</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="clientcallasync">
<code>
client.callAsync
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Call a command on Redis. Allow Redis to block the execution if needed (like
<code>
blpop
</code>
command) and return the result asynchronously. Returns a promise object that will be resolved when the command invocation finished.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">callAsync</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">''</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">...</span><span class="nx">args</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="clientcallasyncraw">
<code>
client.callAsyncRaw
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Call a command on Redis. Allow Redis to block the execution if needed (like
<code>
blpop
</code>
command) and return the result asynchronously. Returns a promise object that will be resolved when the command invocation finished. The command is executed on the current Redis instrance.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">callRaw</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">''</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">...</span><span class="nx">args</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="clientisblockallowed">
<code>
client.isBlockAllowed
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Return true if it is allow to return promise from the function callback. In case it is allowed and a promise is return, Redis will wait for the promise to be fulfilled and only then will return the function result.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">isBlockAllowed</span><span class="p">();</span> <span class="c1">// True / False
</span></span></span></code></pre>
</div>
<h3 id="clientexecuteasync">
<code>
client.executeAsync
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Execute the given function asynchroniusly. Return a promise that will be fulfilled when the promise will be resolved/rejected.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">executeAsync</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="kr">async</span> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">){}</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h2 id="async-client-object">
Async client object
</h2>
<p>
Background client object that is used to perform background operation on Redis.
This client is given to any background task that runs as a JS coroutine.
</p>
<h3 id="async_clientblock">
<code>
async_client.block
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Blocks Redis for command invocation. All the command that are executed inside the given function is considered atomic and will be wrapped with
<code>
Multi/Exec
</code>
and send to the replica/AOF.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">async_client</span><span class="p">.</span><span class="nx">block</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="kd">function</span><span class="p">(</span><span class="nx">client</span><span class="p">){}</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="async_clientrunonkey">
<code>
async_client.runOnKey
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Runs a remote function on a given key. If the key located on the current shard on which we currently runs on, the remote function will run write away. Otherwise the remote function will run on the remote shard. Returns a promise which will be fulfilled when the invocation finishes. Notice that the remote function must return a json serializable result so we can serialize the result back to the original shard.
</p>
<p>
Notice that remote function can only perform read operations, not writes are allowed.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">async_client</span><span class="p">.</span><span class="nx">runOnKey</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'key1'</span><span class="p">,</span> <span class="c1">// key
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">// function name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">...</span><span class="nx">args</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="async_clientrunonshards">
<code>
async_client.runOnShards
</code>
</h3>
<ul>
<li>
Since version: 2.0.0
</li>
</ul>
<p>
Runs a remote function on all the shards. Returns a promise which will be fulfilled when the invocation finishes on all the shards.
</p>
<p>
The result is array of 2 elements, the first is another array of all the results. The second is an array of all the errors happened durring the invocation. Notice that the remote function must return a json serializable result so we can serialize the result back to the original shard.
</p>
<p>
Notice that remote function can only perform read operations, not writes are allowed.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="nx">async_client</span><span class="p">.</span><span class="nx">runOnShards</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'foo'</span><span class="p">,</span> <span class="c1">//name
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">...</span><span class="nx">args</span> <span class="c1">//arguments
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">)</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/concepts/javascript_api/"/>
<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/task/status/.html | <section class="prose w-full py-12 max-w-none">
<h1>
crdb-cli task status
</h1>
<p class="text-lg -mt-5 mb-10">
Shows the status of a specified Active-Active database task.
</p>
<p>
Shows the status of a specified Active-Active database task.
</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 <task_id>
</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>
task-id <task_id>
</td>
<td>
string
</td>
<td>
An Active-Active database task ID (required)
</td>
</tr>
<tr>
<td>
verbose
</td>
<td>
N/A
</td>
<td>
Returns detailed information when specified
</td>
</tr>
<tr>
<td>
no-verbose
</td>
<td>
N/A
</td>
<td>
Returns limited information when specified
</td>
</tr>
</tbody>
</table>
<p>
The
<code>
--verbose
</code>
and
<code>
--no-verbose
</code>
options are mutually incompatible; specify one or the other.
</p>
<p>
The
<code>
404 Not Found
</code>
error indicates an invalid task ID. Use the
<a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/task/list/">
<code>
task list
</code>
</a>
command to determine available task IDs.
</p>
<h3 id="returns">
Returns
</h3>
<p>
Returns the status of an Active-Active database task.
</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 task status --task-id e1c49470-ae0b-4df8-885b-9c755dd614d0
</span></span><span class="line"><span class="cl">Task-ID: e1c49470-ae0b-4df8-885b-9c755dd614d0
</span></span><span class="line"><span class="cl">CRDB-GUID: 1d7741cc-1110-4e2f-bc6c-935292783d24
</span></span><span class="line"><span class="cl">Operation: create_crdb
</span></span><span class="line"><span class="cl">Status: finished
</span></span><span class="line"><span class="cl">Worker-Name: crdb_worker:1:0
</span></span><span class="line"><span class="cl">Started: 2022-10-12T09:33:41Z
</span></span><span class="line"><span class="cl">Ended: 2022-10-12T09:33:55Z
</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/task/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/clients/jedis/connect/.html | <section class="prose w-full py-12">
<h1>
Connect to the server
</h1>
<p class="text-lg -mt-5 mb-10">
Connect your Java application to a Redis database
</p>
<h2 id="basic-connection">
Basic connection
</h2>
<p>
The following code opens a basic connection to a local Redis server:
</p>
<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">org.example</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></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Main</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</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 class="c1">// Code that interacts with Redis...
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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>
<p>
After you have connected, you can check the connection by storing and
retrieving a simple string value:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="o">...</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">res1</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">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span 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">// 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">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">get</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">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="o">...</span>
</span></span></code></pre>
</div>
<h3 id="connect-to-a-redis-cluster">
Connect to a Redis cluster
</h3>
<p>
To connect to a Redis cluster, use
<code>
JedisCluster
</code>
.
</p>
<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.JedisCluster</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.HostAndPort</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">//...
</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"><</span><span class="n">HostAndPort</span><span class="o">></span> <span class="n">jedisClusterNodes</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashSet</span><span class="o"><</span><span class="n">HostAndPort</span><span class="o">>();</span>
</span></span><span class="line"><span class="cl"><span class="n">jedisClusterNodes</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="k">new</span> <span class="n">HostAndPort</span><span class="o">(</span><span class="s">"127.0.0.1"</span><span class="o">,</span> <span class="mi">7379</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="n">jedisClusterNodes</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="k">new</span> <span class="n">HostAndPort</span><span class="o">(</span><span class="s">"127.0.0.1"</span><span class="o">,</span> <span class="mi">7380</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="n">JedisCluster</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">JedisCluster</span><span class="o">(</span><span class="n">jedisClusterNodes</span><span class="o">);</span>
</span></span></code></pre>
</div>
<h3 id="connect-to-your-production-redis-with-tls">
Connect to your production Redis with TLS
</h3>
<p>
When you deploy your application, use TLS and follow the
<a href="/docs/latest/operate/oss_and_stack/management/security/">
Redis security
</a>
guidelines.
</p>
<p>
Before connecting your application to the TLS-enabled Redis server, ensure that your certificates and private keys are in the correct format.
</p>
<p>
To convert user certificate and private key from the PEM format to
<code>
pkcs12
</code>
, use this command:
</p>
<pre tabindex="0"><code>openssl pkcs12 -export -in ./redis_user.crt -inkey ./redis_user_private.key -out redis-user-keystore.p12 -name "redis"
</code></pre>
<p>
Enter password to protect your
<code>
pkcs12
</code>
file.
</p>
<p>
Convert the server (CA) certificate to the JKS format using the
<a href="https://docs.oracle.com/en/java/javase/12/tools/keytool.html">
keytool
</a>
shipped with JDK.
</p>
<pre tabindex="0"><code>keytool -importcert -keystore truststore.jks \
-storepass REPLACE_WITH_YOUR_PASSWORD \
-file redis_ca.pem
</code></pre>
<p>
Establish a secure connection with your Redis database using this snippet.
</p>
<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">org.example</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.*</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">javax.net.ssl.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.io.FileInputStream</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.io.IOException</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.security.GeneralSecurityException</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.security.KeyStore</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">Main</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">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">GeneralSecurityException</span><span class="o">,</span> <span class="n">IOException</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">HostAndPort</span> <span class="n">address</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HostAndPort</span><span class="o">(</span><span class="s">"my-redis-instance.cloud.redislabs.com"</span><span class="o">,</span> <span class="mi">6379</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SSLSocketFactory</span> <span class="n">sslFactory</span> <span class="o">=</span> <span class="n">createSslSocketFactory</span><span class="o">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"./truststore.jks"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">"secret!"</span><span class="o">,</span> <span class="c1">// use the password you specified for keytool command
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="s">"./redis-user-keystore.p12"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">"secret!"</span> <span class="c1">// use the password you specified for openssl command
</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 class="n">JedisClientConfig</span> <span class="n">config</span> <span class="o">=</span> <span class="n">DefaultJedisClientConfig</span><span class="o">.</span><span class="na">builder</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">ssl</span><span class="o">(</span><span class="kc">true</span><span class="o">).</span><span class="na">sslSocketFactory</span><span class="o">(</span><span class="n">sslFactory</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">user</span><span class="o">(</span><span class="s">"default"</span><span class="o">)</span> <span class="c1">// use your Redis user. More info https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">.</span><span class="na">password</span><span class="o">(</span><span class="s">"secret!"</span><span class="o">)</span> <span class="c1">// use your Redis password
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">.</span><span class="na">build</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">JedisPooled</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">JedisPooled</span><span class="o">(</span><span class="n">address</span><span class="o">,</span> <span class="n">config</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">set</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"foo"</span><span class="o">));</span> <span class="c1">// prints bar
</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 class="kd">private</span> <span class="kd">static</span> <span class="n">SSLSocketFactory</span> <span class="nf">createSslSocketFactory</span><span class="o">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">caCertPath</span><span class="o">,</span> <span class="n">String</span> <span class="n">caCertPassword</span><span class="o">,</span> <span class="n">String</span> <span class="n">userCertPath</span><span class="o">,</span> <span class="n">String</span> <span class="n">userCertPassword</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="kd">throws</span> <span class="n">IOException</span><span class="o">,</span> <span class="n">GeneralSecurityException</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">KeyStore</span> <span class="n">keyStore</span> <span class="o">=</span> <span class="n">KeyStore</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="s">"pkcs12"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">keyStore</span><span class="o">.</span><span class="na">load</span><span class="o">(</span><span class="k">new</span> <span class="n">FileInputStream</span><span class="o">(</span><span class="n">userCertPath</span><span class="o">),</span> <span class="n">userCertPassword</span><span class="o">.</span><span class="na">toCharArray</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">KeyStore</span> <span class="n">trustStore</span> <span class="o">=</span> <span class="n">KeyStore</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="s">"jks"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">trustStore</span><span class="o">.</span><span class="na">load</span><span class="o">(</span><span class="k">new</span> <span class="n">FileInputStream</span><span class="o">(</span><span class="n">caCertPath</span><span class="o">),</span> <span class="n">caCertPassword</span><span class="o">.</span><span class="na">toCharArray</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">TrustManagerFactory</span> <span class="n">trustManagerFactory</span> <span class="o">=</span> <span class="n">TrustManagerFactory</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="s">"X509"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">trustManagerFactory</span><span class="o">.</span><span class="na">init</span><span class="o">(</span><span class="n">trustStore</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">KeyManagerFactory</span> <span class="n">keyManagerFactory</span> <span class="o">=</span> <span class="n">KeyManagerFactory</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="s">"PKIX"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">keyManagerFactory</span><span class="o">.</span><span class="na">init</span><span class="o">(</span><span class="n">keyStore</span><span class="o">,</span> <span class="n">userCertPassword</span><span class="o">.</span><span class="na">toCharArray</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SSLContext</span> <span class="n">sslContext</span> <span class="o">=</span> <span class="n">SSLContext</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="s">"TLS"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">sslContext</span><span class="o">.</span><span class="na">init</span><span class="o">(</span><span class="n">keyManagerFactory</span><span class="o">.</span><span class="na">getKeyManagers</span><span class="o">(),</span> <span class="n">trustManagerFactory</span><span class="o">.</span><span class="na">getTrustManagers</span><span class="o">(),</span> <span class="kc">null</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="n">sslContext</span><span class="o">.</span><span class="na">getSocketFactory</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>
<h2 id="connect-using-client-side-caching">
Connect using client-side caching
</h2>
<p>
Client-side caching is a technique to reduce network traffic between
the client and server, resulting in better performance. See
<a href="/docs/latest/develop/clients/client-side-caching/">
Client-side caching introduction
</a>
for more information about how client-side caching works and how to use it effectively.
</p>
<p>
To enable client-side caching, specify the
<a href="/docs/latest/develop/reference/protocol-spec/#resp-versions">
RESP3
</a>
protocol and pass a cache configuration object during the connection.
</p>
<p>
The example below shows the simplest client-side caching connection to the default host and port,
<code>
localhost:6379
</code>
.
All of the connection variants described above accept these parameters, so you can
use client-side caching with a connection pool or a cluster connection in exactly the same way.
</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>
Client-side caching requires Jedis v5.2.0 or later.
To maximize compatibility with all Redis products, client-side caching
is supported by Redis v7.4 or later.
</div>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">HostAndPort</span> <span class="n">endpoint</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HostAndPort</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">6379</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">DefaultJedisClientConfig</span> <span class="n">config</span> <span class="o">=</span> <span class="n">DefaultJedisClientConfig</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">builder</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">password</span><span class="o">(</span><span class="s">"secretPassword"</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">protocol</span><span class="o">(</span><span class="n">RedisProtocol</span><span class="o">.</span><span class="na">RESP3</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">build</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">CacheConfig</span> <span class="n">cacheConfig</span> <span class="o">=</span> <span class="n">CacheConfig</span><span class="o">.</span><span class="na">builder</span><span class="o">().</span><span class="na">maxSize</span><span class="o">(</span><span class="mi">1000</span><span class="o">).</span><span class="na">build</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">UnifiedJedis</span> <span class="n">client</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="n">endpoint</span><span class="o">,</span> <span class="n">config</span><span class="o">,</span> <span class="n">cacheConfig</span><span class="o">);</span>
</span></span></code></pre>
</div>
<p>
Once you have connected, the usual Redis commands will work transparently
with the cache:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"city"</span><span class="o">,</span> <span class="s">"New York"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"city"</span><span class="o">);</span> <span class="c1">// Retrieved from Redis server and cached
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"city"</span><span class="o">);</span> <span class="c1">// Retrieved from cache
</span></span></span></code></pre>
</div>
<p>
You can see the cache working if you connect to the same Redis database
with
<a href="/docs/latest/develop/tools/cli/">
<code>
redis-cli
</code>
</a>
and run the
<a href="/docs/latest/commands/monitor/">
<code>
MONITOR
</code>
</a>
command. If you run the
code above but without passing
<code>
cacheConfig
</code>
during the connection,
you should see the following in the CLI among the output from
<code>
MONITOR
</code>
:
</p>
<pre tabindex="0"><code>1723109720.268903 [...] "SET" "city" "New York"
1723109720.269681 [...] "GET" "city"
1723109720.270205 [...] "GET" "city"
</code></pre>
<p>
The server responds to both
<code>
get("city")
</code>
calls.
If you run the code with
<code>
cacheConfig
</code>
added in again, you will see
</p>
<pre tabindex="0"><code>1723110248.712663 [...] "SET" "city" "New York"
1723110248.713607 [...] "GET" "city"
</code></pre>
<p>
The first
<code>
get("city")
</code>
call contacted the server, but the second
call was satisfied by the cache.
</p>
<h3 id="removing-items-from-the-cache">
Removing items from the cache
</h3>
<p>
You can remove individual keys from the cache with the
<code>
deleteByRedisKey()
</code>
method of the cache object. This removes all cached items associated
with each specified key, so all results from multi-key commands (such as
<a href="/docs/latest/commands/mget/">
<code>
MGET
</code>
</a>
) and composite data structures
(such as
<a href="/docs/latest/develop/data-types/hashes/">
hashes
</a>
) will be
cleared at once. The example below shows the effect of removing a single
key from the cache:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">Cache</span> <span class="n">myCache</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="na">getCache</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="n">myCache</span><span class="o">.</span><span class="na">deleteByRedisKey</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Still read from the cache
</span></span></span></code></pre>
</div>
<p>
You can also clear all cached items using the
<code>
flush()
</code>
method:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">Cache</span> <span class="n">myCache</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="na">getCache</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="n">myCache</span><span class="o">.</span><span class="na">flush</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:1"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the server
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">client</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"person:2"</span><span class="o">,</span> <span class="s">"name"</span><span class="o">);</span> <span class="c1">// Read from the cache
</span></span></span></code></pre>
</div>
<p>
The client will also flush the cache automatically
if any connection (including one from a connection pool)
is disconnected.
</p>
<h2 id="connect-with-a-connection-pool">
Connect with a connection pool
</h2>
<p>
For production usage, you should use a connection pool to manage
connections rather than opening and closing connections individually.
A connection pool maintains several open connections and reuses them
efficiently. When you open a connection from a pool, the pool allocates
one of its open connections. When you subsequently close the same connection,
it is not actually closed but simply returned to the pool for reuse.
This avoids the overhead of repeated connecting and disconnecting.
See
<a href="/docs/latest/develop/clients/pools-and-muxing/">
Connection pools and multiplexing
</a>
for more information.
</p>
<p>
Use the following code to connect with a connection pool:
</p>
<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">org.example</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.Jedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.JedisPool</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">Main</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">JedisPool</span> <span class="n">pool</span> <span class="o">=</span> <span class="k">new</span> <span class="n">JedisPool</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">6379</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">Jedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="na">getResource</span><span class="o">())</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Store & Retrieve a simple string
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"foo"</span><span class="o">));</span> <span class="c1">// prints bar
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Store & Retrieve a HashMap
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hash</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();;</span>
</span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"name"</span><span class="o">,</span> <span class="s">"John"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"surname"</span><span class="o">,</span> <span class="s">"Smith"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"company"</span><span class="o">,</span> <span class="s">"Redis"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"age"</span><span class="o">,</span> <span class="s">"29"</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">hset</span><span class="o">(</span><span class="s">"user-session:123"</span><span class="o">,</span> <span class="n">hash</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">hgetAll</span><span class="o">(</span><span class="s">"user-session:123"</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Prints: {name=John, surname=Smith, company=Redis, age=29}
</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 class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<p>
Because adding a
<code>
try-with-resources
</code>
block for each command can be cumbersome, consider using
<code>
JedisPooled
</code>
as an easier way to pool connections.
<code>
JedisPooled
</code>
, added in Jedis version 4.0.0, provides capabilities similar to
<code>
JedisPool
</code>
but with a more straightforward API.
</p>
<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.JedisPooled</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">//...
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="n">JedisPooled</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">JedisPooled</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">6379</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">set</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"foo"</span><span class="o">));</span> <span class="c1">// prints "bar"
</span></span></span></code></pre>
</div>
<p>
A connection pool holds a specified number of connections, creates more connections when necessary, and terminates them when they are no longer needed.
</p>
<p>
Here is a simplified connection lifecycle in a pool:
</p>
<ol>
<li>
A connection is requested from the pool.
</li>
<li>
A connection is served:
<ul>
<li>
An idle connection is served when non-active connections are available, or
</li>
<li>
A new connection is created when the number of connections is under
<code>
maxTotal
</code>
.
</li>
</ul>
</li>
<li>
The connection becomes active.
</li>
<li>
The connection is released back to the pool.
</li>
<li>
The connection is marked as stale.
</li>
<li>
The connection is kept idle for
<code>
minEvictableIdleTime
</code>
.
</li>
<li>
The connection becomes evictable if the number of connections is greater than
<code>
minIdle
</code>
.
</li>
<li>
The connection is ready to be closed.
</li>
</ol>
<p>
It's important to configure the connection pool correctly.
Use
<code>
GenericObjectPoolConfig
</code>
from
<a href="https://commons.apache.org/proper/commons-pool/apidocs/org/apache/commons/pool2/impl/GenericObjectPoolConfig.html">
Apache Commons Pool2
</a>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">ConnectionPoolConfig</span> <span class="n">poolConfig</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ConnectionPoolConfig</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="c1">// maximum active connections in the pool,
</span></span></span><span class="line"><span class="cl"><span class="c1">// tune this according to your needs and application type
</span></span></span><span class="line"><span class="cl"><span class="c1">// default is 8
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setMaxTotal</span><span class="o">(</span><span class="mi">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">// maximum idle connections in the pool, default is 8
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setMaxIdle</span><span class="o">(</span><span class="mi">8</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// minimum idle connections in the pool, default 0
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setMinIdle</span><span class="o">(</span><span class="mi">0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Enables waiting for a connection to become available.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setBlockWhenExhausted</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// The maximum number of seconds to wait for a connection to become available
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setMaxWait</span><span class="o">(</span><span class="n">Duration</span><span class="o">.</span><span class="na">ofSeconds</span><span class="o">(</span><span class="mi">1</span><span class="o">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Enables sending a PING command periodically while the connection is idle.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setTestWhileIdle</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// controls the period between checks for idle connections in the pool
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">poolConfig</span><span class="o">.</span><span class="na">setTimeBetweenEvictionRuns</span><span class="o">(</span><span class="n">Duration</span><span class="o">.</span><span class="na">ofSeconds</span><span class="o">(</span><span class="mi">1</span><span class="o">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// JedisPooled does all hard work on fetching and releasing connection to the pool
</span></span></span><span class="line"><span class="cl"><span class="c1">// to prevent connection starvation
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">JedisPooled</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">JedisPooled</span><span class="o">(</span><span class="n">poolConfig</span><span class="o">,</span> <span class="s">"localhost"</span><span class="o">,</span> <span class="mi">6379</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/develop/clients/jedis/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/operate/rs/7.4/references/rest-api/objects/role/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Role object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents a role
</p>
<p>
An API object that represents a role.
</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>
Role'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 GET /actions/{uid} API (read-only)
</td>
</tr>
<tr>
<td>
management
</td>
<td>
'admin'
<br/>
'db_member'
<br/>
'db_viewer'
<br/>
'cluster_member'
<br/>
'cluster_viewer'
<br/>
'none'
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#roles">
Management role
</a>
</td>
</tr>
<tr>
<td>
name
</td>
<td>
string
</td>
<td>
Role's name
</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/role/"/>
<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/access-control/social-login/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Social login
</h1>
<p class="text-lg -mt-5 mb-10">
Social login with Redis Cloud.
</p>
<p>
Redis Cloud supports the following social logins:
</p>
<ul>
<li>
<a href="https://github.com/">
GitHub
</a>
</li>
<li>
<a href="https://accounts.google.com/">
Google
</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>
If your Google and GitHub accounts share an email address (such as Gmail), you can use either one to sign in to the same Redis Cloud account.
</div>
</div>
<h2 id="create-a-new-account-with-social-login">
Create a new account with social login
</h2>
<p>
To set up Google login:
</p>
<ol>
<li>
Select
<strong>
Google
</strong>
from the
<a href="https://cloud.redis.io/">
sign-in
</a>
screen.
</li>
<li>
Sign in with the Google account you would like to use.
</li>
<li>
Select
<strong>
Confirm
</strong>
on the
<strong>
Sign in with Google
</strong>
prompt.
</li>
</ol>
<p>
To set up GitHub login:
</p>
<ol>
<li>
Select
<strong>
Github
</strong>
from the
<a href="https://cloud.redis.io/">
sign-in
</a>
screen.
</li>
<li>
Sign in with the Github account you would like to use.
</li>
<li>
Select
<strong>
Authorize
</strong>
on the
<strong>
Authorize Redis Okta Auth Github
</strong>
prompt.
</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 the email address associated with your GitHub account is not public, you will see an error message that your sign in attempt failed. You need to
<a href="https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences">
make your email address public
</a>
on GitHub before you try again.
</div>
</div>
<h2 id="migrate-an-existing-account-to-social-login">
Migrate an existing account to social login
</h2>
<p>
If you already have a Redis Cloud account that requires an email address and password to sign in, you can migrate your existing account to use a social login associated with that same email address instead.
</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>
Once you migrate your account to use social login, you cannot revert to your old email/password sign in method.
</div>
</div>
<p>
To migrate your account to Google social login:
</p>
<ol>
<li>
Select
<strong>
Google
</strong>
on the
<a href="https://cloud.redis.io/">
sign-in
</a>
screen.
</li>
<li>
Choose your preferred account from the list.
</li>
<li>
A confirmation prompt will display and warn that you cannot revert to your old sign in method if you proceed with the migration to social login.
</li>
<li>
Select
<strong>
Confirm
</strong>
to continue migration.
</li>
</ol>
<p>
To migrate your account to GitHub social login:
</p>
<ol>
<li>
Select
<strong>
Github
</strong>
on the
<a href="https://cloud.redis.io/">
sign-in
</a>
screen.
</li>
<li>
Select
<strong>
Authorize
</strong>
on the
<strong>
Authorize Redis Okta Auth Github
</strong>
prompt.
</li>
<li>
Enter your GitHub password to
<strong>
Confirm access
</strong>
. A confirmation prompt warns that you cannot revert to your old sign-in method if you proceed with the migration to social login.
</li>
<li>
Select
<strong>
Confirm
</strong>
to continue migration.
</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/rc/security/access-control/social-login/"/>
<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/asyncforeach/.html | <section class="prose w-full py-12 max-w-none">
<h1>
AsyncForeach
</h1>
<p class="text-lg -mt-5 mb-10">
For each record in the pipe, asynchronously runs some operations.
</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="n">GearsBuilder</span><span class="o"><</span><span class="n">T</span><span class="o">></span> <span class="n">asyncForeach</span><span class="err"></span><span class="o">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">gears</span><span class="o">.</span><span class="na">operations</span><span class="o">.</span><span class="na">AsyncForeachOperation</span><span class="o"><</span><span class="n">T</span><span class="o">></span> <span class="n">foreach</span><span class="o">)</span>
</span></span></code></pre>
</div>
<p>
The
<code>
asyncForeach
</code>
function allows you to use a
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsfuture/">
<code>
GearsFuture
</code>
</a>
object to define a set of operations and run them asynchronously for each record in the pipe.
</p>
<h2 id="parameters">
Parameters
</h2>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
foreach
</td>
<td>
AsyncForeachOperation
<t>
</t>
</td>
<td>
The set of operations to run for each record
</td>
</tr>
</tbody>
</table>
<h2 id="returns">
Returns
</h2>
<p>
Returns a GearsBuilder object with a new template type.
</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">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">-></span><span class="n">r</span><span class="o">.</span><span class="na">getKey</span><span class="o">()).</span>
</span></span><span class="line"><span class="cl"> <span class="n">asyncForeach</span><span class="o">(</span><span class="n">r</span><span class="o">->{</span>
</span></span><span class="line"><span class="cl"> <span class="n">GearsFuture</span><span class="o"><</span><span class="n">Serializable</span><span class="o">></span> <span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GearsFuture</span><span class="o"><</span><span class="n">Serializable</span><span class="o">>();</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Thread</span><span class="o">(</span><span class="k">new</span> <span class="n">Runnable</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nd">@Override</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="k">try</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">Thread</span><span class="o">.</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">f</span><span class="o">.</span><span class="na">setResult</span><span class="o">(</span><span class="n">r</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="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 class="na">start</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">f</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><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/asyncforeach/"/>
<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/administration/extensions/.html | <section class="prose w-full py-12">
<h1>
Extend existing search and query features
</h1>
<p class="text-lg -mt-5 mb-10">
Details about extensions for query expanders and scoring functions
</p>
<p>
RediSearch supports an extension mechanism, much like Redis supports modules. The API is very minimal at the moment, and it does not yet support dynamic loading of extensions on a running server. Instead, extensions must be written in C (or a language that has an interface with C) and compiled into dynamic libraries that can be loaded at start up.
</p>
<p>
There are two kinds of extension APIs at the moment:
</p>
<ol>
<li>
<strong>
Query expanders
</strong>
, whose role is to expand query tokens (i.e., stemmers).
</li>
<li>
<strong>
Scoring functions
</strong>
, whose role is to rank search results at query time.
</li>
</ol>
<h2 id="registering-and-loading-extensions">
Registering and loading extensions
</h2>
<p>
Extensions should be compiled into dynamic library files (e.g.,
<code>
.so
</code>
files), and loaded into the RediSearch module during initialization.
</p>
<h3 id="compiling">
Compiling
</h3>
<pre><code>Extensions should be compiled and linked as dynamic libraries. An example Makefile for an extension [can be found here](https://github.com/RediSearch/RediSearch/blob/master/tests/ctests/ext-example/Makefile).
That folder also contains an example extension that is used for testing and can be taken as a skeleton for implementing your own extension.
</code></pre>
<h3 id="loading">
Loading
</h3>
<pre><code>Loading an extension is done by appending `EXTLOAD {path/to/ext.so}` after the `loadmodule` configuration directive when loading the RediSearch module. For example:
```sh
$ redis-server --loadmodule ./redisearch.so EXTLOAD ./ext/my_extension.so
```
This causes the RediSearch module to automatically load the extension and register its expanders and scorers.
</code></pre>
<h2 id="initializing-an-extension">
Initializing an extension
</h2>
<p>
The entry point of an extension is a function with the signature:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="kt">int</span> <span class="nf">RS_ExtensionInit</span><span class="p">(</span><span class="n">RSExtensionCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">);</span>
</span></span></code></pre>
</div>
<p>
When loading an extension, RediSearch looks for this function and calls it. This function is responsible for registering and initializing the expanders and scorers.
</p>
<p>
It should return REDISEARCH_ERR on error or REDISEARCH_OK on success.
</p>
<h3 id="example-init-function">
Example init function
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf"><redisearch.h> //must be in the include path</span><span class="cp">
</span></span></span><span class="line"><span class="cl"><span class="cp"></span>
</span></span><span class="line"><span class="cl"><span class="kt">int</span> <span class="nf">RS_ExtensionInit</span><span class="p">(</span><span class="n">RSExtensionCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* Register a scoring function with an alias my_scorer and no special private data and free function */</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">ctx</span><span class="o">-></span><span class="nf">RegisterScoringFunction</span><span class="p">(</span><span class="s">"my_scorer"</span><span class="p">,</span> <span class="n">MyCustomScorer</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">)</span> <span class="o">==</span> <span class="n">REDISEARCH_ERR</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">REDISEARCH_ERR</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* Register a query expander */</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">ctx</span><span class="o">-></span><span class="nf">RegisterQueryExpander</span><span class="p">(</span><span class="s">"my_expander"</span><span class="p">,</span> <span class="n">MyExpander</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">)</span> <span class="o">==</span>
</span></span><span class="line"><span class="cl"> <span class="n">REDISEARCH_ERR</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">REDISEARCH_ERR</span><span class="p">;</span>
</span></span><span class="line"><span 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">return</span> <span class="n">REDISEARCH_OK</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h2 id="calling-your-custom-functions">
Calling your custom functions
</h2>
<p>
When performing a query, you can use your scorers or expanders by specifying the SCORER or EXPANDER arguments with the given alias. For example:
</p>
<pre tabindex="0"><code>FT.SEARCH my_index "foo bar" EXPANDER my_expander SCORER my_scorer
</code></pre>
<p>
<strong>
NOTE
</strong>
: Expander and scorer aliases are
<strong>
case sensitive
</strong>
.
</p>
<h2 id="the-query-expander-api">
The query expander API
</h2>
<p>
Only basic query expansion is supported, one token at a time. An expander can decide to expand any given token with as many tokens it wishes, which will be union-merged in query time.
</p>
<p>
The API for an expander is the following:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf"><redisearch.h> //must be in the include path</span><span class="cp">
</span></span></span><span class="line"><span class="cl"><span class="cp"></span>
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="nf">MyQueryExpander</span><span class="p">(</span><span class="n">RSQueryExpanderCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="n">RSToken</span> <span class="o">*</span><span class="n">token</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="p">}</span>
</span></span></code></pre>
</div>
<h3 id="rsqueryexpanderctx">
RSQueryExpanderCtx
</h3>
<p>
<code>
RSQueryExpanderCtx
</code>
is a context that contains private data of the extension, and a callback method to expand the query. It is defined as:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="k">typedef</span> <span class="k">struct</span> <span class="n">RSQueryExpanderCtx</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* Opaque query object used internally by the engine, and should not be accessed */</span>
</span></span><span class="line"><span class="cl"> <span class="k">struct</span> <span class="n">RSQuery</span> <span class="o">*</span><span class="n">query</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* Opaque query node object used internally by the engine, and should not be accessed */</span>
</span></span><span class="line"><span class="cl"> <span class="k">struct</span> <span class="n">RSQueryNode</span> <span class="o">**</span><span class="n">currentNode</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* Private data of the extension, set on extension initialization */</span>
</span></span><span class="line"><span class="cl"> <span class="kt">void</span> <span class="o">*</span><span class="n">privdata</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* The language of the query, defaults to "english" */</span>
</span></span><span class="line"><span class="cl"> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">language</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* ExpandToken allows the user to add an expansion of the token in the query, that will be
</span></span></span><span class="line"><span class="cl"><span class="cm"> * union-merged with the given token in query time. str is the expanded string, len is its length,
</span></span></span><span class="line"><span class="cl"><span class="cm"> * and flags is a 32 bit flag mask that can be used by the extension to set private information on
</span></span></span><span class="line"><span class="cl"><span class="cm"> * the token */</span>
</span></span><span class="line"><span class="cl"> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">ExpandToken</span><span class="p">)(</span><span class="k">struct</span> <span class="n">RSQueryExpanderCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">str</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">len</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">RSTokenFlags</span> <span class="n">flags</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* SetPayload allows the query expander to set GLOBAL payload on the query (not unique per token)
</span></span></span><span class="line"><span class="cl"><span class="cm"> */</span>
</span></span><span class="line"><span class="cl"> <span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">SetPayload</span><span class="p">)(</span><span class="k">struct</span> <span class="n">RSQueryExpanderCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="n">RSPayload</span> <span class="n">payload</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 class="n">RSQueryExpanderCtx</span><span class="p">;</span>
</span></span></code></pre>
</div>
<h3 id="rstoken">
RSToken
</h3>
<p>
<code>
RSToken
</code>
represents a single query token to be expanded, and is defined as:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="cm">/* A token in the query. The expanders receive query tokens and can expand the query with more query
</span></span></span><span class="line"><span class="cl"><span class="cm"> * tokens */</span>
</span></span><span class="line"><span class="cl"><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="cm">/* The token string - which may or may not be NULL terminated */</span>
</span></span><span class="line"><span class="cl"> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">str</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"> <span class="cm">/* The token length */</span>
</span></span><span class="line"><span class="cl"> <span class="kt">size_t</span> <span class="n">len</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* 1 if the token is the result of query expansion */</span>
</span></span><span class="line"><span class="cl"> <span class="kt">uint8_t</span> <span class="nl">expanded</span><span class="p">:</span><span class="mi">1</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/* Extension specific token flags that can be examined later by the scoring function */</span>
</span></span><span class="line"><span class="cl"> <span class="n">RSTokenFlags</span> <span class="n">flags</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="n">RSToken</span><span class="p">;</span>
</span></span></code></pre>
</div>
<h2 id="the-scoring-function-api">
The scoring function API
</h2>
<p>
For the final ranking, the scoring function analyzes each document retrieved by the query, taking into account not only the terms that triggered the document's retrieval but also metadata like its prior score, length, and so on.
</p>
<p>
Since the scoring function is evaluated for each document, potentially millions of times, and since
redis is single threaded, it is important that it works as fast as possible and be heavily optimized.
</p>
<p>
A scoring function is applied to each potential result for each document and is implemented with the following signature:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="kt">double</span> <span class="nf">MyScoringFunction</span><span class="p">(</span><span class="n">RSScoringFunctionCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="n">RSIndexResult</span> <span class="o">*</span><span class="n">res</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">RSDocumentMetadata</span> <span class="o">*</span><span class="n">dmd</span><span class="p">,</span> <span class="kt">double</span> <span class="n">minScore</span><span class="p">);</span>
</span></span></code></pre>
</div>
<p>
<code>
RSScoringFunctionCtx
</code>
is a context that implements some helper methods.
</p>
<p>
<code>
RSIndexResult
</code>
is the result information containing the document id, frequency, terms, and offsets.
</p>
<p>
<code>
RSDocumentMetadata
</code>
is an object holding global information about the document, such as its presumptive score.
</p>
<p>
<code>
minScore
</code>
is the minimal score that will yield a result that is relevant to the search. It can be used to stop processing midway or before or even before it starts.
</p>
<p>
The return value of the function is a
<code>
double
</code>
representing the final score of the result.
Returning 0 causes the result to be counted, but if there are results with a score greater than 0, they will appear above it.
To completely filter out a result and not count it in the totals, the scorer should return the special value
<code>
RS_SCORE_FILTEROUT
</code>
, which is internally set to negative infinity, or -1/0.
</p>
<h3 id="rsscoringfunctionctx">
RSScoringFunctionCtx
</h3>
<p>
This is an object containing the following members:
</p>
<ul>
<li>
<code>
void *privdata
</code>
: a pointer to an object set by the extension on initialization time.
</li>
<li>
<code>
RSPayload payload*
</code>
: A Payload object set either by the query expander or the client.
</li>
<li>
<code>
int GetSlop(RSIndexResult *res)*
</code>
: A callback method that yields the total minimal distance between the query terms. This can be used to prefer results where the slop is smaller and the terms are nearer to each other.
</li>
</ul>
<h3 id="rsindexresult">
RSIndexResult
</h3>
<p>
This is an object holding the information about the current result in the index, which is an aggregate of all the terms that resulted in the current document being considered a valid result. See
<code>
redisearch.h
</code>
for details.
</p>
<h3 id="rsdocumentmetadata">
RSDocumentMetadata
</h3>
<p>
This is an object describing global information, unrelated to the current query, about the document being evaluated by the scoring function.
</p>
<h2 id="example-query-expander">
Example query expander
</h2>
<p>
This example query expander expands each token with the term foo:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf"><redisearch.h> //must be in the include path</span><span class="cp">
</span></span></span><span class="line"><span class="cl"><span class="cp"></span>
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="nf">DummyExpander</span><span class="p">(</span><span class="n">RSQueryExpanderCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="n">RSToken</span> <span class="o">*</span><span class="n">token</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">ctx</span><span class="o">-></span><span class="nf">ExpandToken</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="nf">strdup</span><span class="p">(</span><span class="s">"foo"</span><span class="p">),</span> <span class="nf">strlen</span><span class="p">(</span><span class="s">"foo"</span><span class="p">),</span> <span class="mh">0x1337</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h2 id="example-scoring-function">
Example scoring function
</h2>
<p>
This is an actual scoring function, which calculates TF-IDF for the document, multiplies it by the document score, and divides it by the slop:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf"><redisearch.h> //must be in the include path</span><span class="cp">
</span></span></span><span class="line"><span class="cl"><span class="cp"></span>
</span></span><span class="line"><span class="cl"><span class="kt">double</span> <span class="nf">TFIDFScorer</span><span class="p">(</span><span class="n">RSScoringFunctionCtx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span> <span class="n">RSIndexResult</span> <span class="o">*</span><span class="n">h</span><span class="p">,</span> <span class="n">RSDocumentMetadata</span> <span class="o">*</span><span class="n">dmd</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">minScore</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// no need to evaluate documents with score 0
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="k">if</span> <span class="p">(</span><span class="n">dmd</span><span class="o">-></span><span class="n">score</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// calculate sum(tf-idf) for each term in the result
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="kt">double</span> <span class="n">tfidf</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">h</span><span class="o">-></span><span class="n">numRecords</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// take the term frequency and multiply by the term IDF, add that to the total
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">tfidf</span> <span class="o">+=</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span><span class="n">h</span><span class="o">-></span><span class="n">records</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">freq</span> <span class="o">*</span> <span class="p">(</span><span class="n">h</span><span class="o">-></span><span class="n">records</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">term</span> <span class="o">?</span> <span class="n">h</span><span class="o">-></span><span class="n">records</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">term</span><span class="o">-></span><span class="nl">idf</span> <span class="p">:</span> <span class="mi">0</span><span 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="c1">// normalize by the maximal frequency of any term in the document
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">tfidf</span> <span class="o">/=</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span><span class="n">dmd</span><span class="o">-></span><span class="n">maxFreq</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// multiply by the document score (between 0 and 1)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">tfidf</span> <span class="o">*=</span> <span class="n">dmd</span><span class="o">-></span><span class="n">score</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// no need to factor the slop if tfidf is already below minimal score
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="k">if</span> <span class="p">(</span><span class="n">tfidf</span> <span class="o"><</span> <span class="n">minScore</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// get the slop and divide the result by it, making sure we prefer results with closer terms
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">tfidf</span> <span class="o">/=</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span><span class="n">ctx</span><span class="o">-></span><span class="nf">GetSlop</span><span class="p">(</span><span class="n">h</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">tfidf</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</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/develop/interact/search-and-query/administration/extensions/"/>
<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/probabilistic/hyperloglogs/.html | <section class="prose w-full py-12">
<h1>
HyperLogLog
</h1>
<p class="text-lg -mt-5 mb-10">
HyperLogLog is a probabilistic data structure that estimates the cardinality of a set.
</p>
<p>
HyperLogLog is a probabilistic data structure that estimates the cardinality of a set. As a probabilistic data structure, HyperLogLog trades perfect accuracy for efficient space utilization.
</p>
<p>
The Redis HyperLogLog implementation uses up to 12 KB and provides a standard error of 0.81%.
</p>
<p>
Counting unique items usually requires an amount of memory
proportional to the number of items you want to count, because you need
to remember the elements you have already seen in the past in order to avoid
counting them multiple times. However, a set of algorithms exist that trade
memory for precision: they return an estimated measure with a standard error,
which, in the case of the Redis implementation for HyperLogLog, is less than 1%.
The magic of this algorithm is that you no longer need to use an amount of memory
proportional to the number of items counted, and instead can use a
constant amount of memory; 12k bytes in the worst case, or a lot less if your
HyperLogLog (We'll just call them HLL from now) has seen very few elements.
</p>
<p>
HLLs in Redis, while technically a different data structure, are encoded
as a Redis string, so you can call
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
to serialize a HLL, and
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
to deserialize it back to the server.
</p>
<p>
Conceptually the HLL API is like using Sets to do the same task. You would
<a href="/docs/latest/commands/sadd/">
<code>
SADD
</code>
</a>
every observed element into a set, and would use
<a href="/docs/latest/commands/scard/">
<code>
SCARD
</code>
</a>
to check the
number of elements inside the set, which are unique since
<a href="/docs/latest/commands/sadd/">
<code>
SADD
</code>
</a>
will not
re-add an existing element.
</p>
<p>
While you don't really
<em>
add items
</em>
into an HLL, because the data structure
only contains a state that does not include actual elements, the API is the
same:
</p>
<ul>
<li>
Every time you see a new element, you add it to the count with
<a href="/docs/latest/commands/pfadd/">
<code>
PFADD
</code>
</a>
.
</li>
<li>
When you want to retrieve the current approximation of unique elements added using the
<a href="/docs/latest/commands/pfadd/">
<code>
PFADD
</code>
</a>
command, you can use the
<a href="/docs/latest/commands/pfcount/">
<code>
PFCOUNT
</code>
</a>
command. If you need to merge two different HLLs, the
<a href="/docs/latest/commands/pfmerge/">
<code>
PFMERGE
</code>
</a>
command is available. Since HLLs provide approximate counts of unique elements, the result of the merge will give you an approximation of the number of unique elements across both source HLLs.
</li>
</ul>
<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="hll_tutorial-steppfadd">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_hll_tutorial-steppfadd" name="hll_tutorial-steppfadd" 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_hll_tutorial-steppfadd" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-hll_tutorial-steppfadd" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_hll_tutorial-steppfadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> PFADD bikes Hyperion Deimos Phoebe Quaoar
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> PFCOUNT bikes
</span></span><span class="line hl"><span class="cl">(integer) 4
</span></span><span class="line hl"><span class="cl">> PFADD commuter_bikes Salacia Mimas Quaoar
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> PFMERGE all_bikes bikes commuter_bikes
</span></span><span class="line hl"><span class="cl">OK
</span></span><span class="line hl"><span class="cl">> PFCOUNT all_bikes
</span></span><span class="line hl"><span class="cl">(integer) 6</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_hll_tutorial-steppfadd')" 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_hll_tutorial-steppfadd" name="hll_tutorial-steppfadd" 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_hll_tutorial-steppfadd" title="Open example">
Python
</label>
<div aria-labelledby="tab-hll_tutorial-steppfadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_hll_tutorial-steppfadd" 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 HyperLogLog doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/hyperloglogs/
</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></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">pfadd</span><span class="p">(</span><span class="s2">"bikes"</span><span class="p">,</span> <span class="s2">"Hyperion"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"Phoebe"</span><span class="p">,</span> <span class="s2">"Quaoar"</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"># >>> 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">pfcount</span><span class="p">(</span><span class="s2">"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">res2</span><span class="p">)</span> <span class="c1"># >>> 4</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">pfadd</span><span class="p">(</span><span class="s2">"commuter_bikes"</span><span class="p">,</span> <span class="s2">"Salacia"</span><span class="p">,</span> <span class="s2">"Mimas"</span><span class="p">,</span> <span class="s2">"Quaoar"</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"># >>> 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">pfmerge</span><span class="p">(</span><span class="s2">"all_bikes"</span><span class="p">,</span> <span class="s2">"bikes"</span><span class="p">,</span> <span class="s2">"commuter_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">res4</span><span class="p">)</span> <span class="c1"># >>> True</span>
</span></span><span class="line hl"><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">pfcount</span><span class="p">(</span><span class="s2">"all_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">res5</span><span class="p">)</span> <span class="c1"># >>> 6</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_hll_tutorial-steppfadd')" 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_hll_tutorial-steppfadd" 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_hll.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_hll_tutorial-steppfadd" name="hll_tutorial-steppfadd" 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_hll_tutorial-steppfadd" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-hll_tutorial-steppfadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_hll_tutorial-steppfadd" 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="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></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">pfAdd</span><span class="p">(</span><span class="s1">'bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'Hyperion'</span><span class="p">,</span> <span class="s1">'Deimos'</span><span class="p">,</span> <span class="s1">'Phoebe'</span><span class="p">,</span> <span class="s1">'Quaoar'</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">// >>> 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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">pfCount</span><span class="p">(</span><span class="s1">'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">res2</span><span class="p">);</span> <span class="c1">// >>> 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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">pfAdd</span><span class="p">(</span><span class="s1">'commuter_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'Salacia'</span><span class="p">,</span> <span class="s1">'Mimas'</span><span class="p">,</span> <span class="s1">'Quaoar'</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">// >>> 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">pfMerge</span><span class="p">(</span><span class="s1">'all_bikes'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'bikes'</span><span class="p">,</span> <span class="s1">'commuter_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">res4</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">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">pfCount</span><span class="p">(</span><span class="s1">'all_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">res5</span><span class="p">);</span> <span class="c1">// >>> 6
</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_hll_tutorial-steppfadd')" 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_hll_tutorial-steppfadd" 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-hll.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_hll_tutorial-steppfadd" name="hll_tutorial-steppfadd" 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_hll_tutorial-steppfadd" title="Open example">
Java
</label>
<div aria-labelledby="tab-hll_tutorial-steppfadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_hll_tutorial-steppfadd" 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.Assert</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">redis.clients.jedis.UnifiedJedis</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">HyperLogLogExample</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></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">pfadd</span><span class="o">(</span><span class="s">"bikes"</span><span class="o">,</span> <span class="s">"Hyperion"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">,</span> <span class="s">"Phoebe"</span><span class="o">,</span> <span class="s">"Quaoar"</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">// >>> 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">pfcount</span><span class="o">(</span><span class="s">"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">res2</span><span class="o">);</span> <span class="c1">// >>> 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="kt">long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">pfadd</span><span class="o">(</span><span class="s">"commuter_bikes"</span><span class="o">,</span> <span class="s">"Salacia"</span><span class="o">,</span> <span class="s">"Mimas"</span><span class="o">,</span> <span class="s">"Quaoar"</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">// >>> 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">pfmerge</span><span class="o">(</span><span class="s">"all_bikes"</span><span class="o">,</span> <span class="s">"bikes"</span><span class="o">,</span> <span class="s">"commuter_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">res4</span><span class="o">);</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></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">pfcount</span><span class="o">(</span><span class="s">"all_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">res5</span><span class="o">);</span> <span class="c1">// >>> 6
</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 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_hll_tutorial-steppfadd')" 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_hll_tutorial-steppfadd" 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/HyperLogLogExample.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_hll_tutorial-steppfadd" name="hll_tutorial-steppfadd" 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_hll_tutorial-steppfadd" title="Open example">
Go
</label>
<div aria-labelledby="tab-hll_tutorial-steppfadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_hll_tutorial-steppfadd" 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_pfadd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span 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">PFAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes"</span><span class="p">,</span> <span class="s">"Hyperion"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="s">"Phoebe"</span><span class="p">,</span> <span class="s">"Quaoar"</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">// 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">PFCount</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"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">res2</span><span class="p">)</span> <span class="c1">// 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">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">PFAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"commuter_bikes"</span><span class="p">,</span> <span class="s">"Salacia"</span><span class="p">,</span> <span class="s">"Mimas"</span><span class="p">,</span> <span class="s">"Quaoar"</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">// 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">PFMerge</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"all_bikes"</span><span class="p">,</span> <span class="s">"bikes"</span><span class="p">,</span> <span class="s">"commuter_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">res4</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="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">PFCount</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"all_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">res5</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="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_hll_tutorial-steppfadd')" 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_hll_tutorial-steppfadd" 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/hll_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_hll_tutorial-steppfadd" name="hll_tutorial-steppfadd" 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_hll_tutorial-steppfadd" title="Open example">
C#
</label>
<div aria-labelledby="tab-hll_tutorial-steppfadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_hll_tutorial-steppfadd" 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">Hll_tutorial</span>
</span></span><span class="line"><span 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">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HyperLogLogAdd</span><span class="p">(</span><span class="s">"{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">"Hyperion"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="s">"Phoebe"</span><span class="p">,</span> <span class="s">"Quaoar"</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">// >>> True</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">HyperLogLogLength</span><span class="p">(</span><span class="s">"{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">res2</span><span class="p">);</span> <span class="c1">// >>> 4</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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HyperLogLogAdd</span><span class="p">(</span><span class="s">"commuter_{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">"Salacia"</span><span class="p">,</span> <span class="s">"Mimas"</span><span class="p">,</span> <span class="s">"Quaoar"</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">// >>> True</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">HyperLogLogMerge</span><span class="p">(</span><span class="s">"all_{bikes}"</span><span class="p">,</span> <span class="s">"{bikes}"</span><span class="p">,</span> <span class="s">"commuter_{bikes}"</span><span class="p">);</span>
</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">HyperLogLogLength</span><span class="p">(</span><span class="s">"all_{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">res4</span><span class="p">);</span> <span class="c1">// >>> 6</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'pfadd' 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_hll_tutorial-steppfadd')" 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_hll_tutorial-steppfadd" 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/Hll_tutorial.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>
Some examples of use cases for this data structure is counting unique queries
performed by users in a search form every day, number of unique visitors to a web page and other similar cases.
</p>
<p>
Redis is also able to perform the union of HLLs, please check the
<a href="/docs/latest/commands/#hyperloglog">
full documentation
</a>
for more information.
</p>
<h2 id="use-cases">
Use cases
</h2>
<p>
<strong>
Anonymous unique visits of a web page (SaaS, analytics tools)
</strong>
</p>
<p>
This application answers these questions:
</p>
<ul>
<li>
How many unique visits has this page had on this day?
</li>
<li>
How many unique users have played this song?
</li>
<li>
How many unique users have viewed this video?
</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>
Storing the IP address or any other kind of personal identifier is against the law in some countries, which makes it impossible to get unique visitor statistics on your website.
</div>
</div>
<p>
One HyperLogLog is created per page (video/song) per period, and every IP/identifier is added to it on every visit.
</p>
<h2 id="basic-commands">
Basic commands
</h2>
<ul>
<li>
<a href="/docs/latest/commands/pfadd/">
<code>
PFADD
</code>
</a>
adds an item to a HyperLogLog.
</li>
<li>
<a href="/docs/latest/commands/pfcount/">
<code>
PFCOUNT
</code>
</a>
returns an estimate of the number of items in the set.
</li>
<li>
<a href="/docs/latest/commands/pfmerge/">
<code>
PFMERGE
</code>
</a>
combines two or more HyperLogLogs into one.
</li>
</ul>
<p>
See the
<a href="/docs/latest/commands/?group=hyperloglog">
complete list of HyperLogLog commands
</a>
.
</p>
<h2 id="performance">
Performance
</h2>
<p>
Writing (
<a href="/docs/latest/commands/pfadd/">
<code>
PFADD
</code>
</a>
) to and reading from (
<a href="/docs/latest/commands/pfcount/">
<code>
PFCOUNT
</code>
</a>
) the HyperLogLog is done in constant time and space.
Merging HLLs is O(n), where
<em>
n
</em>
is the number of sketches.
</p>
<h2 id="limits">
Limits
</h2>
<p>
The HyperLogLog can estimate the cardinality of sets with up to 18,446,744,073,709,551,616 (2^64) members.
</p>
<h2 id="learn-more">
Learn more
</h2>
<ul>
<li>
<a href="http://antirez.com/news/75">
Redis new data structure: the HyperLogLog
</a>
has a lot of details about the data structure and its implementation in Redis.
</li>
<li>
<a href="https://www.youtube.com/watch?v=MunL8nnwscQ">
Redis HyperLogLog Explained
</a>
shows you how to use Redis HyperLogLog data structures to build a traffic heat map.
</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/probabilistic/hyperloglogs/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Reference
</h1>
<nav>
<a href="/docs/latest/operate/rs/7.4/references/supported-platforms/">
Supported platforms
</a>
<p>
Redis Enterprise Software is supported on several operating systems, cloud environments, and virtual environments.
</p>
<a href="/docs/latest/operate/rs/7.4/references/upgrade-paths/">
Supported upgrade paths for Redis Software
</a>
<p>
Supported paths to upgrade a Redis Software cluster.
</p>
<a href="/docs/latest/operate/rs/7.4/references/client_references/">
Develop with Redis clients
</a>
<p>
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>
<a href="/docs/latest/operate/rs/7.4/references/memtier-benchmark/">
Benchmark an Auto Tiering enabled database
</a>
<br/>
<br/>
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/">
Command-line utilities
</a>
<p>
Reference for Redis Enterprise Software command-line utilities, including rladmin, redis-cli, crdb-cli, and rlcheck.
</p>
<a href="/docs/latest/operate/rs/7.4/references/metrics/">
Real-time metrics
</a>
<p>
Documents the metrics that are tracked with Redis Enterprise Software.
</p>
<a href="/docs/latest/operate/rs/7.4/references/compatibility/">
Redis Enterprise compatibility with Redis Community Edition
</a>
<p>
Redis Enterprise compatibility with Redis Community Edition.
</p>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
<p>
Documents the REST API available to Redis Enterprise Software deployments.
</p>
<a href="/docs/latest/operate/rs/7.4/references/terminology/">
Terminology in Redis Enterprise Software
</a>
<p>
Explains terms used in Redis Enterprise Software and its docs.
</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/operate/rs/7.4/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/rs/7.4/installing-upgrading/upgrading/upgrade-active-active/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Upgrade an Active-Active database
</h1>
<p class="text-lg -mt-5 mb-10">
Upgrade an Active-Active database.
</p>
<p>
When you upgrade an
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
Active-Active (CRDB) database
</a>
, you can also upgrade the CRDB protocol version and feature version.
</p>
<h2 id="crdb-protocol-version-guidelines">
CRDB protocol version guidelines
</h2>
<p>
Redis Enterprise Software versions 5.4.2 and later use CRDB protocol version 1 to help support Active-Active features.
</p>
<p>
CRDB protocol version 1 is backward compatible, which means Redis Enterprise v5.4.2 CRDB instances can understand write operations from instances using the earlier CRDB protocol version 0.
</p>
<p>
After you upgrade one instance's CRDB protocol to version 1:
</p>
<ul>
<li>
<p>
Any instances that use CRDB protocol version 1 can receive updates from both version 1 and version 0 instances.
</p>
</li>
<li>
<p>
However, instances that still use CRDB protocol version 0 cannot receive write updates from version 1 instances.
</p>
</li>
<li>
<p>
After you upgrade an instance from CRDB protocol version 0 to version 1, it automatically receives any missing write operations.
</p>
</li>
</ul>
<p>
Follow these upgrade guidelines:
</p>
<ul>
<li>
<p>
Upgrade all instances of a specific CRDB within a reasonable time frame to avoid temporary inconsistencies between the instances.
</p>
</li>
<li>
<p>
Make sure that you upgrade all instances of a specific CRDB before you do global operations on the CRDB, such as removing instances and adding new instances.
</p>
</li>
<li>
<p>
As of v6.0.20, protocol version 0 is deprecated and support will be removed in a future version.
</p>
</li>
<li>
<p>
To avoid upgrade failures, update all Active-Active databases to protocol version 1
<em>
before
</em>
upgrading Redis Enterprise Software to v6.0.20 or later.
</p>
</li>
</ul>
<h2 id="feature-version-guidelines">
Feature version guidelines
</h2>
<p>
Starting with version 5.6.0, a new feature version (also called a
<em>
feature set version
</em>
) helps support new Active-Active features.
</p>
<p>
When you update the feature version for an Active-Active database, the feature version is updated for all database instances.
</p>
<p>
Follow these upgrade guidelines:
</p>
<ul>
<li>
<p>
As of v6.0.20, feature version 0 is deprecated and support will be removed in a future version.
</p>
</li>
<li>
<p>
To avoid upgrade failures, update all Active-Active databases to protocol version 1
<em>
before
</em>
upgrading Redis Enterprise Software to v6.0.20 or later.
</p>
</li>
</ul>
<h2 id="upgrade-active-active-database-instance">
Upgrade Active-Active database instance
</h2>
<p>
To upgrade an Active-Active database (CRDB) instance:
</p>
<ol>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-cluster/">
Upgrade Redis Enterprise Software
</a>
on each node in the clusters where the Active-Active instances are located.
</p>
</li>
<li>
<p>
To see the status of your Active-Active instances, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin status
</span></span></code></pre>
</div>
<p>
The statuses of the Active-Active instances on the node can indicate:
</p>
<ul>
<li>
<code>
OLD REDIS VERSION
</code>
</li>
<li>
<code>
OLD CRDB PROTOCOL VERSION
</code>
</li>
<li>
<code>
OLD CRBD FEATURESET VERSION
</code>
</li>
</ul>
<a href="/docs/latest/images/rs/crdb-upgrade-node.png" sdata-lightbox="/images/rs/crdb-upgrade-node.png">
<img src="/docs/latest/images/rs/crdb-upgrade-node.png"/>
</a>
</li>
<li>
<p>
To upgrade each Active-Active instance, including the Redis version and CRDB protocol version, run:
</p>
<ul>
<li>
<p>
To upgrade a database without modules:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin upgrade db <database_name <span class="p">|</span> database_ID>
</span></span></code></pre>
</div>
</li>
<li>
<p>
If the database has modules enabled and new module versions are available in the cluster, run
<code>
rladmin upgrade db
</code>
with additional parameters to upgrade the module versions when you upgrade the database. See
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/upgrade-module/">
Upgrade modules
</a>
for more details.
</p>
</li>
</ul>
<p>
If the protocol version is old, read the warning message carefully and confirm.
</p>
<a href="/docs/latest/images/rs/crdb-upgrade-protocol.png" sdata-lightbox="/images/rs/crdb-upgrade-protocol.png">
<img src="/docs/latest/images/rs/crdb-upgrade-protocol.png"/>
</a>
<p>
The Active-Active instance uses the new Redis version and CRDB protocol version.
</p>
<p>
Use the
<code>
keep_crdt_protocol_version
</code>
option to upgrade the database feature version
without upgrading the CRDB protocol version.
</p>
<p>
If you use this option, make sure that you upgrade the CRDB protocol soon after with the
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/upgrade/#upgrade-db">
<code>
rladmin upgrade db
</code>
</a>
command.
</p>
<p>
You must upgrade the CRDB protocol before you update the CRDB feature set version.
</p>
</li>
<li>
<p>
If the feature set version is old, you must upgrade all of the Active-Active instances. Then, to update the feature set for each 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 update --crdb-guid <CRDB-GUID> --featureset-version yes
</span></span></code></pre>
</div>
<p>
You can retrieve the
<code>
<CRDB-GUID>
</code>
with the following command:
</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>
Look for the fully qualified domain name (CLUSTER-FDQN) of your cluster and use the associated GUID:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">CRDB-GUID NAME REPL-ID CLUSTER-FQDN
</span></span><span class="line"><span class="cl">700140c5-478e-49d7-ad3c-64d517ddc486 aatest <span class="m">1</span> aatest1.example.com
</span></span><span class="line"><span class="cl">700140c5-478e-49d7-ad3c-64d517ddc486 aatest <span class="m">2</span> aatest2.example.com
</span></span></code></pre>
</div>
</li>
<li>
<p>
Update module information in the CRDB configuration using the following command syntax:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb update --crdb-guid <guid> --default-db-config <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span><span class="s1">'{ "module_list":
</span></span></span><span class="line"><span class="cl"><span class="s1"> [
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "<module1_name>",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "<module1_version>"
</span></span></span><span class="line"><span class="cl"><span class="s1"> },
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "<module2_name>",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "<module2_version>"
</span></span></span><span class="line"><span class="cl"><span class="s1"> }
</span></span></span><span class="line"><span class="cl"><span class="s1"> ]}'</span>
</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 update --crdb-guid 82a80988-f5fe-4fa5-bca0-aef2a0fd60db --default-db-config <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span><span class="s1">'{ "module_list":
</span></span></span><span class="line"><span class="cl"><span class="s1"> [
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "search",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "2.4.6"
</span></span></span><span class="line"><span class="cl"><span class="s1"> },
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "ReJSON",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "2.4.5"
</span></span></span><span class="line"><span class="cl"><span class="s1"> }
</span></span></span><span class="line"><span class="cl"><span class="s1"> ]}'</span>
</span></span></code></pre>
</div>
</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/7.4/installing-upgrading/upgrading/upgrade-active-active/"/>
<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/pfdebug/.html | <section class="prose w-full py-12">
<h1 class="command-name">
PFDEBUG
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">PFDEBUG subcommand 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.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>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<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>
PFDEBUG
</code>
command is an internal command.
It is meant to be used for developing and testing Redis.
</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/pfdebug/"/>
<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/hget/.html | <section class="prose w-full py-12">
<h1 class="command-name">
HGET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">HGET key field</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(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>
@hash
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Returns the value associated with
<code>
field
</code>
in the hash stored at
<code>
key
</code>
.
</p>
<h2 id="examples">
Examples
</h2>
<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_hash-stephget">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_hash-stephget" name="cmds_hash-stephget" 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_hash-stephget" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-cmds_hash-stephget" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_hash-stephget" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> HSET myhash field1 "foo"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> HGET myhash field1
</span></span><span class="line hl"><span class="cl">"foo"
</span></span><span class="line hl"><span class="cl">> HGET myhash field2
</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_cmds_hash-stephget')" 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_hash-stephget" name="cmds_hash-stephget" 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_hash-stephget" title="Open example">
Python
</label>
<div aria-labelledby="tab-cmds_hash-stephget" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_hash-stephget" 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">host</span><span class="o">=</span><span class="s2">"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 class="n">db</span><span class="o">=</span><span class="mi">0</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">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</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">res1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 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">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</span><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></span><span class="line"><span class="cl"><span class="c1"># >>> Hello</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">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">"field2"</span><span class="p">:</span> <span class="s2">"Hi"</span><span class="p">,</span> <span class="s2">"field3"</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">res3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 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">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field2"</span><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></span><span class="line"><span class="cl"><span class="c1"># >>> Hi</span>
</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">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field3"</span><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></span><span class="line"><span class="cl"><span class="c1"># >>> World</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">hgetall</span><span class="p">(</span><span class="s2">"myhash"</span><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></span><span class="line"><span class="cl"><span class="c1"># >>> { "field1": "Hello", "field2": "Hi", "field3": "World" }</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">res7</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="s2">"field1"</span><span class="p">,</span> <span class="s2">"foo"</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></span><span class="line hl"><span class="cl"><span class="c1"># >>> 1</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">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</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></span><span class="line hl"><span class="cl"><span class="c1"># >>> foo</span>
</span></span><span class="line hl"><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">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field2"</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></span><span class="line hl"><span class="cl"><span class="c1"># >>> None</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_hash-stephget')" 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_hash-stephget" 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_hash.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_hash-stephget" name="cmds_hash-stephget" 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_hash-stephget" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-cmds_hash-stephget" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_hash-stephget" 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">'node: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="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">res1</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="s1">'field1'</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">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">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</span><span class="p">)</span>
</span></span><span class="line"><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">// Hello
</span></span></span><span class="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">hSet</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'myhash'</span><span 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="s1">'field2'</span><span class="o">:</span> <span class="s1">'Hi'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'field3'</span><span class="o">:</span> <span class="s1">'World'</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="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">// 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">)</span>
</span></span><span class="line"><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">// Hi
</span></span></span><span class="line"><span class="cl"><span class="c1"></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">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field3'</span><span class="p">)</span>
</span></span><span class="line"><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">// World
</span></span></span><span class="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">hGetAll</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">)</span>
</span></span><span class="line"><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></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">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">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'foo'</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">// 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">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</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">// foo
</span></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">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field2'</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">// foo
</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="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><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_Nodejs_cmds_hash-stephget')" 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_hash-stephget" 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-hash.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_hash-stephget" name="cmds_hash-stephget" 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_hash-stephget" title="Open example">
Java
</label>
<div aria-labelledby="tab-cmds_hash-stephget" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_hash-stephget" 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></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsHashExample</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></span><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 'hdel' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hexists' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hexpire' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hexpireat' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hexpiretime' step.
</span></span></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">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hGetExampleParams</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">hGetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field1"</span><span class="o">,</span> <span class="s">"foo"</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">hGetResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="n">hGetExampleParams</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">hGetResult1</span><span class="o">);</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="n">String</span> <span class="n">hGetResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field1"</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">hGetResult2</span><span class="o">);</span> <span class="c1">// >>> foo
</span></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">hGetResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field2"</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">hGetResult3</span><span class="o">);</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 class="c1">// Tests for 'hget' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hgetall' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hincrby' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hincrbyfloat' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hkeys' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hlen' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hmget' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hmset' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hpersist' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hpexpire' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hpexpireat' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hpexpiretime' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hpttl' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hrandfield' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hscan' step.
</span></span></span><span class="line"><span 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">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hSetExampleParams</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field1"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">hSetResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="n">hSetExampleParams</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult1</span><span class="o">);</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="n">String</span> <span class="n">hSetResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field1"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult2</span><span class="o">);</span> <span class="c1">// >>> Hello
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">clear</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field2"</span><span class="o">,</span> <span class="s">"Hi"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field3"</span><span class="o">,</span> <span class="s">"World"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">hSetResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span><span class="n">hSetExampleParams</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult3</span><span class="o">);</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="n">String</span> <span class="n">hSetResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field2"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult4</span><span class="o">);</span> <span class="c1">// >>> Hi
</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">hSetResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field3"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult5</span><span class="o">);</span> <span class="c1">// >>> World
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hSetResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hgetAll</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="n">String</span> <span class="n">key</span><span class="o">:</span> <span class="n">hSetResult6</span><span class="o">.</span><span class="na">keySet</span><span class="o">())</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Key: "</span> <span class="o">+</span> <span class="n">key</span> <span class="o">+</span> <span class="s">", Value: "</span> <span class="o">+</span> <span class="n">hSetResult6</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">key</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="c1">// >>> Key: field3, Value: World
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Key: field2, Value: Hi
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Key: field1, Value: Hello
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hset' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hsetnx' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hstrlen' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'httl' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><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 'hvals' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</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_hash-stephget')" 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_hash-stephget" 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/CmdsHashExample.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_hash-stephget" name="cmds_hash-stephget" 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_hash-stephget" title="Open example">
Go
</label>
<div aria-labelledby="tab-cmds_hash-stephget" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_hash-stephget" 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_hset</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span 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">HSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> Hello
</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">HSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">"field2"</span><span class="p">,</span> <span class="s">"Hi"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">"field3"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> Hi
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</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">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> World
</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">HGetAll</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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></span><span class="line"><span class="cl"> <span class="c1">// >>> map[field1:Hello field2:Hi field3:World]
</span></span></span><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_hget</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span 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">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">HSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"foo"</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">// >>> 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">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">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</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">// >>> foo
</span></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">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">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</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="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">// >>> <empty string>
</span></span></span><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_cmds_hash-stephget')" 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_hash-stephget" 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_hash_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_hash-stephget" name="cmds_hash-stephget" 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_hash-stephget" title="Open example">
C#
</label>
<div aria-labelledby="tab-cmds_hash-stephget" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_hash-stephget" 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">CmdsHashExample</span>
</span></span><span class="line"><span 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">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashSet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"foo"</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="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</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">// >>> foo</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">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</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">// >>> Null</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hget' 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashSet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</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">RedisValue</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> Hello</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">HashSet</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"myhash"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"field2"</span><span class="p">,</span> <span class="s">"Hi"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"field3"</span><span class="p">,</span> <span class="s">"World"</span><span 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></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> Hi</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">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field3"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> World</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">HashEntry</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGetAll</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">);</span>
</span></span><span class="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">$"{string.Join("</span><span class="p">,</span> <span class="s">", res8.Select(h => $"</span><span class="p">{</span><span class="n">h</span><span class="p">.</span><span class="n">Name</span><span class="p">}:</span> <span class="p">{</span><span class="n">h</span><span class="p">.</span><span class="n">Value</span><span class="p">}</span><span class="s">"))}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> field1: Hello, field2: Hi, field3: World</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hset' step.</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></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_hash-stephget')" 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_hash-stephget" 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/CmdsHashExample.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>
Give these commands 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> HSET myhash field1 "foo"
(integer) 1
redis> HGET myhash field1
"foo"
redis> HGET myhash field2
(nil)
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<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 value associated with the field.
</li>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Nil reply
</a>
: If the field is not present in the hash or key does not exist.
</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 value associated with the field.
</li>
<li>
<a href="../../develop/reference/protocol-spec#nulls">
Null reply
</a>
: If the field is not present in the hash or key does not exist.
</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/hget/"/>
<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/statistics/db-metrics/.html | <section class="prose w-full py-12 max-w-none">
<h1>
DB metrics
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the DB 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>
avg_latency
</td>
<td>
float
</td>
<td>
Average latency of operations on the DB (microseconds). Only returned when there is traffic.
</td>
</tr>
<tr>
<td>
avg_other_latency
</td>
<td>
float
</td>
<td>
Average latency of other (non read/write) operations (microseconds). Only returned when there is traffic.
</td>
</tr>
<tr>
<td>
avg_read_latency
</td>
<td>
float
</td>
<td>
Average latency of read operations (microseconds). Only returned when there is traffic.
</td>
</tr>
<tr>
<td>
avg_write_latency
</td>
<td>
float
</td>
<td>
Average latency of write operations (microseconds). Only returned when there is traffic.
</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
</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
</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>
Value count on flash (BigRedis). Only returned when BigRedis is enabled.
</td>
</tr>
<tr>
<td>
bigstore_objs_ram
</td>
<td>
float
</td>
<td>
Value 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>
conns
</td>
<td>
float
</td>
<td>
Number of client connections to the DB’s endpoints
</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>
egress_bytes
</td>
<td>
float
</td>
<td>
Rate of outgoing network traffic to the DB’s endpoint (bytes/sec)
</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 all Redis shard fork child processes of this database
</td>
</tr>
<tr>
<td>
fork_cpu_user
</td>
<td>
float
</td>
<td>
% cores utilization in user mode for all Redis shard fork child processes of this database
</td>
</tr>
<tr>
<td>
ingress_bytes
</td>
<td>
float
</td>
<td>
Rate of incoming network traffic to the DB’s endpoint (bytes/sec)
</td>
</tr>
<tr>
<td>
instantaneous_ops_per_sec
</td>
<td>
float
</td>
<td>
Request rate handled by all shards of the DB (ops/sec)
</td>
</tr>
<tr>
<td>
last_req_time
</td>
<td>
date, ISO_8601 format
</td>
<td>
Last request time received to the DB (ISO format 2015-07-05T22:16:18Z). Returns 1/1/1970 when unavailable.
</td>
</tr>
<tr>
<td>
last_res_time
</td>
<td>
date, ISO_8601 format
</td>
<td>
Last response time received from DB (ISO format 2015-07-05T22:16:18Z). Returns 1/1/1970 when unavailable.
</td>
</tr>
<tr>
<td>
main_thread_cpu_system
</td>
<td>
float
</td>
<td>
% cores utilization in system mode for all Redis shard main threads of this database
</td>
</tr>
<tr>
<td>
main_thread_cpu_user
</td>
<td>
float
</td>
<td>
% cores utilization in user mode for all Redis shard main threads of this database
</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>
monitor_sessions_count
</td>
<td>
float
</td>
<td>
Number of client connected in monitor mode to the DB
</td>
</tr>
<tr>
<td>
no_of_expires
</td>
<td>
float
</td>
<td>
Number of volatile keys in the DB
</td>
</tr>
<tr>
<td>
no_of_keys
</td>
<td>
float
</td>
<td>
Number of keys in the DB
</td>
</tr>
<tr>
<td>
other_req
</td>
<td>
float
</td>
<td>
Rate of other (non read/write) requests on DB (ops/sec)
</td>
</tr>
<tr>
<td>
other_res
</td>
<td>
float
</td>
<td>
Rate of other (non read/write) responses on DB (ops/sec)
</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>
ram_overhead
</td>
<td>
float
</td>
<td>
Non values RAM overhead (BigRedis) (bytes). Only returned when BigRedis is enabled.
</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>
read_req
</td>
<td>
float
</td>
<td>
Rate of read requests on DB (ops/sec)
</td>
</tr>
<tr>
<td>
read_res
</td>
<td>
float
</td>
<td>
Rate of read responses on DB (ops/sec)
</td>
</tr>
<tr>
<td>
shard_cpu_system
</td>
<td>
float
</td>
<td>
% cores utilization in system mode for all Redis shard processes of this database
</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_connections_received
</td>
<td>
float
</td>
<td>
Rate of new client connections to the DB (connections/sec)
</td>
</tr>
<tr>
<td>
total_req
</td>
<td>
float
</td>
<td>
Rate of all requests on DB (ops/sec)
</td>
</tr>
<tr>
<td>
total_res
</td>
<td>
float
</td>
<td>
Rate of all responses on DB (ops/sec)
</td>
</tr>
<tr>
<td>
used_bigstore
</td>
<td>
float
</td>
<td>
Flash used by DB (BigRedis) (bytes). Only returned when BigRedis is enabled.
</td>
</tr>
<tr>
<td>
used_memory
</td>
<td>
float
</td>
<td>
Memory used by DB (in BigRedis this includes flash) (bytes)
</td>
</tr>
<tr>
<td>
used_ram
</td>
<td>
float
</td>
<td>
RAM used by DB (BigRedis) (bytes). Only returned when BigRedis is enabled.
</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>
<tr>
<td>
write_req
</td>
<td>
float
</td>
<td>
Rate of write requests on DB (ops/sec)
</td>
</tr>
<tr>
<td>
write_res
</td>
<td>
float
</td>
<td>
Rate of write responses on DB (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/7.4/references/rest-api/objects/statistics/db-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/operate/rs/7.4/installing-upgrading/quickstarts/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software quickstarts
</h1>
<p class="text-lg -mt-5 mb-10">
Follow these quickstarts to try out Redis Enterprise Software.
</p>
<p>
Try out Redis Enterprise Software using one of 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>
<p>
Additional quickstart guides are available to help you:
</p>
<ul>
<li>
<p>
Set up a
<a href="/docs/latest/operate/rs/7.4/databases/auto-tiering/quickstart/">
Auto Tiering cluster
</a>
to optimize memory resources.
</p>
</li>
<li>
<p>
Set up an
<a href="/docs/latest/operate/rs/7.4/databases/active-active/get-started/">
Active-Active cluster
</a>
to enable high availability.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/clusters/optimize/memtier-benchmark/">
Benchmark
</a>
Redis Enterprise Software performance.
</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/quickstarts/"/>
<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/python/recipes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Python-based RedisGears recipes
</h1>
<p>
A RedisGears recipe is a collection of RedisGears functions, often designed to perform a specific, complex task.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
Recipe
</th>
<th style="text-align:left">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/python/recipes/write-behind/">
Write-behind caching
</a>
</td>
<td style="text-align:left">
Write-behind and write-through caching between Redis and other databases (SQL or NoSQL).
</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/gears-v1/python/recipes/"/>
<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/sinter/.html | <section class="prose w-full py-12">
<h1 class="command-name">
SINTER
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">SINTER key [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">
1.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.
</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>
@set
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Returns the members of the set resulting from the intersection of all the given
sets.
</p>
<p>
For example:
</p>
<pre tabindex="0"><code>key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SINTER key1 key2 key3 = {c}
</code></pre>
<p>
Keys that do not exist are considered to be empty sets.
With one of the keys being an empty set, the resulting set is also empty (since
set intersection with an empty set always results in an empty set).
</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> SADD key1 "a"
(integer) 1
redis> SADD key1 "b"
(integer) 1
redis> SADD key1 "c"
(integer) 1
redis> SADD key2 "c"
(integer) 1
redis> SADD key2 "d"
(integer) 1
redis> SADD key2 "e"
(integer) 1
redis> SINTER key1 key2
1) "c"
</pre>
<div class="prompt" style="">
<span>
redis>
</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>
: an array with the members of the resulting set.
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#sets">
Set reply
</a>
: a set with the members of the resulting set.
<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/sinter/"/>
<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-no-evict/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CLIENT NO-EVICT
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CLIENT NO-EVICT <ON | OFF></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">
7.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>
@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>
<code>
@connection
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The
<code>
CLIENT NO-EVICT
</code>
command sets the
<a href="/docs/latest/develop/reference/clients/#client-eviction">
client eviction
</a>
mode for the current connection.
</p>
<p>
When turned on and client eviction is configured, the current connection will be excluded from the client eviction process even if we're above the configured client eviction threshold.
</p>
<p>
When turned off, the current client will be re-included in the pool of potential clients to be evicted (and evicted if needed).
</p>
<p>
See
<a href="/docs/latest/develop/reference/clients/#client-eviction">
client eviction
</a>
for more details.
</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/client-no-evict/"/>
<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/stats/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Database stats requests
</h1>
<p class="text-lg -mt-5 mb-10">
Database statistics requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-bdbs-stats">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/stats
</code>
</td>
<td>
Get stats for all databases
</td>
</tr>
<tr>
<td>
<a href="#get-bdbs-stats">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/stats/{uid}
</code>
</td>
<td>
Get stats for a specific database
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-bdbs-stats">
Get all database stats
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/stats
</span></span></code></pre>
</div>
<p>
Get statistics for all databases.
</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/#view_all_bdb_stats">
view_all_bdb_stats
</a>
</td>
<td>
admin
<br/>
cluster_member
<br/>
cluster_viewer
<br/>
db_member
<br/>
db_viewer
</td>
</tr>
</tbody>
</table>
<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 /bdbs/stats?interval<span class="o">=</span>1hour<span class="p">&</span><span class="nv">stime</span><span class="o">=</span>2014-08-28T10:00:00Z
</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="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 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-all-response">
Response
</h3>
<p>
Returns
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for all databases.
</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">"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">"1hour"</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">"2015-05-27T12:00:00Z"</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">"2015-05-28T12:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"avg_latency"</span><span class="p">:</span> <span class="mf">0.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="mf">0.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="mf">0.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">"2015-05-28T00:00:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"evicted_objects"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"expired_objects"</span><span class="p">:</span> <span class="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"instantaneous_ops_per_sec"</span><span class="p">:</span> <span class="mf">0.00011973180076628352</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="s2">"1970-01-01T00:00:00Z"</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="s2">"1970-01-01T00:00:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory"</span><span class="p">:</span> <span class="mf">5656299.362068966</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"mem_size_lua"</span><span class="p">:</span> <span class="mf">35840.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"no_of_keys"</span><span class="p">:</span> <span class="mf">0.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="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_misses"</span><span class="p">:</span> <span class="mf">0.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="mf">0.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="mf">0.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="mf">0.0</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="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_misses"</span><span class="p">:</span> <span class="mf">0.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="mf">0.0</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="mf">0.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">"interval"</span><span class="p">:</span> <span class="s2">"1hour"</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">"1hour"</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">"2015-05-27T13:00:00Z"</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">"2015-05-28T13:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"avg_latency"</span><span class="p">:</span> <span class="mf">599.08</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><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">"uid"</span><span class="p">:</span> <span class="s2">"2"</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">"1hour"</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">"2015-05-27T12:00:00Z"</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">"2015-05-28T12:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"avg_latency"</span><span class="p">:</span> <span class="mf">0.0</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><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">"1hour"</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">"2015-05-27T13:00:00Z"</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">"2015-05-28T13:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">
</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><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="get-all-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>
No error
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
No bdbs exist
</td>
</tr>
</tbody>
</table>
<h3 id="example-requests">
Example requests
</h3>
<h4 id="curl">
cURL
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ curl -k -u <span class="s2">"[username]:[password]"</span> -X GET
</span></span><span class="line"><span class="cl"> https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/bdbs/stats?interval<span class="o">=</span>1hour
</span></span></code></pre>
</div>
<h4 id="python">
Python
</h4>
<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">requests</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">url</span> <span class="o">=</span> <span class="s2">"https://[host][:port]/v1/bdbs/stats?interval=1hour"</span>
</span></span><span class="line"><span class="cl"><span class="n">auth</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"[username]"</span><span class="p">,</span> <span class="s2">"[password]"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s2">"GET"</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">text</span><span class="p">)</span>
</span></span></code></pre>
</div>
<h2 id="get-bdbs-stats">
Get database stats
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/stats/<span class="o">{</span>int: uid<span class="o">}</span>
</span></span></code></pre>
</div>
<p>
Get statistics for a specific database.
</p>
<h3 id="permissions-1">
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/#view_bdb_stats">
view_bdb_stats
</a>
</td>
<td>
admin
<br/>
cluster_member
<br/>
cluster_viewer
<br/>
db_member
<br/>
db_viewer
</td>
</tr>
</tbody>
</table>
<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 /bdbs/stats/1?interval<span class="o">=</span>1hour<span class="p">&</span><span class="nv">stime</span><span class="o">=</span>2014-08-28T10:00:00Z
</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>
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 BDB requested.
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters-1">
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 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>
Returns
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for a specific database.
</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="s2">"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">"1hour"</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">"2015-05-27T12:00:00Z"</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">"2015-05-28T12:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"avg_latency"</span><span class="p">:</span> <span class="mf">0.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="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"evicted_objects"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pubsub_channels"</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">"pubsub_patterns"</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">"expired_objects"</span><span class="p">:</span> <span class="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"instantaneous_ops_per_sec"</span><span class="p">:</span> <span class="mf">0.00011973180076628352</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="s2">"1970-01-01T00:00:00Z"</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="s2">"1970-01-01T00:00:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory"</span><span class="p">:</span> <span class="mf">5656299.362068966</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"mem_size_lua"</span><span class="p">:</span> <span class="mf">35840.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"no_of_keys"</span><span class="p">:</span> <span class="mf">0.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="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_misses"</span><span class="p">:</span> <span class="mf">0.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="mf">0.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="mf">0.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="mf">0.0</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="mf">0.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="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_misses"</span><span class="p">:</span> <span class="mf">0.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="mf">0.0</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="mf">0.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">"interval"</span><span class="p">:</span> <span class="s2">"1hour"</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">"2015-05-27T13:00:00Z"</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">"2015-05-28T13:59:59Z"</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><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="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>
No error
</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 does not exist
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7">
406 Not Acceptable
</a>
</td>
<td>
bdb isn't currently active
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4">
503 Service Unavailable
</a>
</td>
<td>
bdb is in recovery state
</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/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/commands/acl-setuser/.html | <section class="prose w-full py-12">
<h1 class="command-name">
ACL SETUSER
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">ACL SETUSER username [rule [rule ...]]</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.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 number of rules provided.
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<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>
Create an ACL user with the specified rules or modify the rules of an
existing user.
</p>
<p>
Manipulate Redis ACL users interactively.
If the username does not exist, the command creates the username without any privilege.
It then reads from left to right all the
<a href="#acl-rules">
rules
</a>
provided as successive arguments, setting the user ACL rules as specified.
If the user already exists, the provided ACL rules are simply applied
<em>
in addition
</em>
to the rules already set. For example:
</p>
<pre><code>ACL SETUSER virginia on allkeys +set
</code></pre>
<p>
The above command creates a user called
<code>
virginia
</code>
who is active(the
<em>
on
</em>
rule), can access any key (
<em>
allkeys
</em>
rule), and can call the set command (
<em>
+set
</em>
rule).
Then, you can use another
<code>
ACL SETUSER
</code>
call to modify the user rules:
</p>
<pre><code>ACL SETUSER virginia +get
</code></pre>
<p>
The above rule applies the new rule to the user
<code>
virginia
</code>
, so other than
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
, the user
<code>
virginia
</code>
can now also use the
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
command.
</p>
<p>
Starting from Redis 7.0, ACL rules can also be grouped into multiple distinct sets of rules, called
<em>
selectors
</em>
.
Selectors are added by wrapping the rules in parentheses and providing them just like any other rule.
In order to execute a command, either the root permissions (rules defined outside of parenthesis) or any of the selectors (rules defined inside parenthesis) must match the given command.
For example:
</p>
<pre><code>ACL SETUSER virginia on +GET allkeys (+SET ~app1*)
</code></pre>
<p>
This sets a user with two sets of permissions, one defined on the user and one defined with a selector.
The root user permissions only allow executing the get command, but can be executed on any keys.
The selector then grants a secondary set of permissions: access to the
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
command to be executed on any key that starts with
<code>
app1
</code>
.
Using multiple selectors allows you to grant permissions that are different depending on what keys are being accessed.
</p>
<p>
When we want to be sure to define a user from scratch, without caring if
it had previously defined rules associated, we can use the special rule
<code>
reset
</code>
as first rule, in order to flush all the other existing rules:
</p>
<pre><code>ACL SETUSER antirez reset [... other rules ...]
</code></pre>
<p>
After resetting a user, its ACL rules revert to the default: inactive, passwordless, can't execute any command nor access any key or channel:
</p>
<pre><code>> ACL SETUSER antirez reset
+OK
> ACL LIST
1) "user antirez off -@all"
</code></pre>
<p>
ACL rules are either words like "on", "off", "reset", "allkeys", or are
special rules that start with a special character, and are followed by
another string (without any space in between), like "+SET".
</p>
<p>
For information on persisting ACLs, see the
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#use-an-external-acl-file">
ACL tutorial
</a>
.
</p>
<p>
The following documentation is a reference manual about the capabilities of this command, however our
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/">
ACL tutorial
</a>
may be a more gentle introduction to how the ACL system works in general.
</p>
<h2 id="acl-rules">
ACL rules
</h2>
<p>
Redis ACL rules are split into two categories: rules that define command permissions or
<em>
command rules
</em>
, and rules that define the user state or
<em>
user management rules
</em>
.
This is a list of all the supported Redis ACL rules:
</p>
<h3 id="command-rules">
Command rules
</h3>
<ul>
<li>
<code>
~<pattern>
</code>
: Adds the specified key pattern (glob style pattern, like in the
<a href="/docs/latest/commands/keys/">
<code>
KEYS
</code>
</a>
command), to the list of key patterns accessible by the user. This grants both read and write permissions to keys that match the pattern. You can add multiple key patterns to the same user. Example:
<code>
~objects:*
</code>
</li>
<li>
<code>
%R~<pattern>
</code>
: (Available in Redis 7.0 and later) Adds the specified read key pattern. This behaves similar to the regular key pattern but only grants permission to read from keys that match the given pattern. See
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#key-permissions">
key permissions
</a>
for more information.
</li>
<li>
<code>
%W~<pattern>
</code>
: (Available in Redis 7.0 and later) Adds the specified write key pattern. This behaves similar to the regular key pattern but only grants permission to write to keys that match the given pattern. See
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#key-permissions">
key permissions
</a>
for more information.
</li>
<li>
<code>
%RW~<pattern>
</code>
: (Available in Redis 7.0 and later) Alias for
<code>
~<pattern>
</code>
.
</li>
<li>
<code>
allkeys
</code>
: Alias for
<code>
~*
</code>
, it allows the user to access all the keys.
</li>
<li>
<code>
resetkeys
</code>
: Removes all the key patterns from the list of key patterns the user can access.
</li>
<li>
<code>
&<pattern>
</code>
: (Available in Redis 6.2 and later) Adds the specified glob style pattern to the list of Pub/Sub channel patterns accessible by the user. You can add multiple channel patterns to the same user. Example:
<code>
&chatroom:*
</code>
</li>
<li>
<code>
allchannels
</code>
: Alias for
<code>
&*
</code>
, it allows the user to access all Pub/Sub channels.
</li>
<li>
<code>
resetchannels
</code>
: Removes all channel patterns from the list of Pub/Sub channel patterns the user can access.
</li>
<li>
<code>
+<command>
</code>
: Adds the command to the list of commands the user can call. Can be used with
<code>
|
</code>
for allowing subcommands (e.g "+config|get").
</li>
<li>
<code>
+@<category>
</code>
: Adds all the commands in the specified category to the list of commands the user is able to execute. Example:
<code>
+@string
</code>
(adds all the string commands). For a list of categories, check the
<a href="/docs/latest/commands/acl-cat/">
<code>
ACL CAT
</code>
</a>
command.
</li>
<li>
<code>
+<command>|first-arg
</code>
: Allows a specific first argument of an otherwise disabled command. It is only supported on commands with no sub-commands, and is not allowed as negative form like -SELECT|1, only additive starting with "+". This feature is deprecated and may be removed in the future.
</li>
<li>
<code>
allcommands
</code>
: Alias of
<code>
+@all
</code>
. Adds all the commands there are in the server, including
<em>
future commands
</em>
loaded via module, to be executed by this user.
</li>
<li>
<code>
-<command>
</code>
: Remove the command to the list of commands the user can call. Starting Redis 7.0, it can be used with
<code>
|
</code>
for blocking subcommands (e.g., "-config|set").
</li>
<li>
<code>
-@<category>
</code>
: Like
<code>
+@<category>
</code>
but removes all the commands in the category instead of adding them.
</li>
<li>
<code>
nocommands
</code>
: Alias for
<code>
-@all
</code>
. Removes all the commands, and the user is no longer able to execute anything.
</li>
</ul>
<h3 id="user-management-rules">
User management rules
</h3>
<ul>
<li>
<code>
on
</code>
: Set the user as active, it will be possible to authenticate as this user using
<code>
AUTH <username> <password>
</code>
.
</li>
<li>
<code>
off
</code>
: Set user as not active, it will be impossible to log as this user. Please note that if a user gets disabled (set to off) after there are connections already authenticated with such a user, the connections will continue to work as expected. To also kill the old connections you can use
<a href="/docs/latest/commands/client-kill/">
<code>
CLIENT KILL
</code>
</a>
with the user option. An alternative is to delete the user with
<a href="/docs/latest/commands/acl-deluser/">
<code>
ACL DELUSER
</code>
</a>
, that will result in all the connections authenticated as the deleted user to be disconnected.
</li>
<li>
<code>
nopass
</code>
: The user is set as a
<em>
no password
</em>
user. It means that it will be possible to authenticate as such user with any password. By default, the
<code>
default
</code>
special user is set as "nopass". The
<code>
nopass
</code>
rule will also reset all the configured passwords for the user.
</li>
<li>
<code>
>password
</code>
: Adds the specified clear text password as a hashed password in the list of the users passwords. Every user can have many active passwords, so that password rotation will be simpler. The specified password is not stored as clear text inside the server. Example:
<code>
>mypassword
</code>
.
</li>
<li>
<code>
#<hashedpassword>
</code>
: Adds the specified hashed password to the list of user passwords. A Redis hashed password is hashed with SHA256 and translated into a hexadecimal string. Example:
<code>
#c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
</code>
.
</li>
<li>
<code>
<password
</code>
: Like
<code>
>password
</code>
but removes the password instead of adding it.
</li>
<li>
<code>
!<hashedpassword>
</code>
: Like
<code>
#<hashedpassword>
</code>
but removes the password instead of adding it.
</li>
<li>
<code>
(<rule list>)
</code>
: (Available in Redis 7.0 and later) Creates a new selector to match rules against. Selectors are evaluated after the user permissions, and are evaluated according to the order they are defined. If a command matches either the user permissions or any selector, it is allowed. See
<a href="/docs/latest/operate/oss_and_stack/management/security/acl#selectors">
selectors
</a>
for more information.
</li>
<li>
<code>
clearselectors
</code>
: (Available in Redis 7.0 and later) Deletes all of the selectors attached to the user.
</li>
<li>
<code>
reset
</code>
: Removes any capability from the user. They are set to off, without passwords, unable to execute any command, unable to access any key.
</li>
</ul>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>> ACL SETUSER alan allkeys +@string +@set -SADD >alanpassword
+OK
> ACL SETUSER antirez heeyyyy
(error) ERR Error in ACL SETUSER modifier 'heeyyyy': Syntax error
</code></pre>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</code>
.
If the rules contain errors, the error is returned.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 6.2.0: Added Pub/Sub channel patterns.
</li>
<li>
Starting with Redis version 7.0.0: Added selectors and key based permissions.
</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/acl-setuser/"/>
<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/snapshot_policy/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Snapshot policy object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the snapshot_policy 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>
secs
</td>
<td>
integer
</td>
<td>
Interval in seconds between snapshots
</td>
</tr>
<tr>
<td>
writes
</td>
<td>
integer
</td>
<td>
Number of write changes required to trigger a snapshot
</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/bdb/snapshot_policy/"/>
<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.get.html | <section class="prose w-full py-12">
<h1 class="command-name">
TS.GET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TS.GET key
[LATEST]
</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>
Get the sample with the highest timestamp from a given 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>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
LATEST
</code>
(since RedisTimeSeries v1.8)
</summary>
<p>
is used when a time series is a compaction. With
<code>
LATEST
</code>
, TS.GET reports the compacted value of the latest (possibly partial) bucket. Without
<code>
LATEST
</code>
, TS.GET does not report the latest (possibly partial) bucket. When a time series is not a compaction,
<code>
LATEST
</code>
is ignored.
</p>
<p>
The data in the latest bucket of a compaction is possibly partial. A bucket is
<em>
closed
</em>
and compacted only upon arrival of a new sample that
<em>
opens
</em>
a new
<em>
latest
</em>
bucket. There are cases, however, when the compacted value of the latest (possibly partial) bucket is also required. In such a case, use
<code>
LATEST
</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/#arrays">
Array reply
</a>
of a single (
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
) pair representing (timestamp, value(double)) of the sample with the highest timestamp
</li>
<li>
An empty
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
- when the time series is empty
</li>
<li>
[] (invalid arguments, wrong key type, key does not exist, etc.)
</li>
</ul>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Get latest measured temperature for a city
</b>
</summary>
<p>
Create a time series to store the temperatures measured in Tel Aviv and add four measurements for Sun Jan 01 2023
</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> TS.CREATE temp:TLV LABELS <span class="nb">type</span> temp location TLV
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD temp:TLV <span class="m">1672534800</span> <span class="m">12</span> temp:TLV <span class="m">1672556400</span> <span class="m">16</span> temp:TLV <span class="m">1672578000</span> <span class="m">21</span> temp:TLV <span class="m">1672599600</span> <span class="m">14</span></span></span></code></pre>
</div>
<p>
Next, get the latest measured temperature (the temperature with the highest timestamp)
</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> TS.GET temp:TLV
</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">1672599600</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="m">14</span></span></span></code></pre>
</div>
</details>
<details open="">
<summary>
<b>
Get latest maximal daily temperature for a city
</b>
</summary>
<p>
Create a time series to store the temperatures measured in Jerusalem
</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> TS.CREATE temp:JLM LABELS <span class="nb">type</span> temp location JLM
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Next, create a compacted time series named
<em>
dailyAvgTemp:JLM
</em>
containing one compacted sample per 24 hours: the maximum 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> TS.CREATE dailyMaxTemp:JLM LABELS <span class="nb">type</span> temp location JLM
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATERULE temp:JLM dailyMaxTemp:JLM AGGREGATION max <span class="m">86400000</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Add four measurements for Sun Jan 01 2023 and three measurements for Mon Jan 02 2023
</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> TS.MADD temp:JLM <span class="m">1672534800000</span> <span class="m">12</span> temp:JLM <span class="m">1672556400000</span> <span class="m">16</span> temp:JLM <span class="m">1672578000000</span> <span class="m">21</span> temp:JLM <span class="m">1672599600000</span> <span class="m">14</span>
</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">1672534800000</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">1672556400000</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">1672578000000</span>
</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">1672599600000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD temp:JLM <span class="m">1672621200000</span> <span class="m">11</span> temp:JLM <span class="m">1672642800000</span> <span class="m">21</span> temp:JLM <span class="m">1672664400000</span> <span class="m">26</span>
</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">1672621200000</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">1672642800000</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">1672664400000</span></span></span></code></pre>
</div>
<p>
Next, get the latest maximum daily temperature; do not report the latest, possibly partial, bucket
</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> TS.GET dailyMaxTemp:JLM
</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">1672531200000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="m">21</span></span></span></code></pre>
</div>
<p>
Get the latest maximum daily temperature (the temperature with the highest timestamp); report the latest, possibly partial, bucket
</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> TS.GET dailyMaxTemp:JLM LATEST
</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">1672617600000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="m">26</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ts.mget/">
<code>
TS.MGET
</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.get/"/>
<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-2.6-release-notes.html | <section class="prose w-full py-12 max-w-none">
<h1>
RediSearch 2.6 release notes
</h1>
<p class="text-lg -mt-5 mb-10">
Search using wildcard queries for TEXT and TAG fields, multi-value indexing and querying of attributes for any attribute type, and indexing double-precision floating-point vectors and range queries from a given vector.
</p>
<h2 id="requirements">
Requirements
</h2>
<p>
RediSearch v2.6.21 requires:
</p>
<ul>
<li>
Minimum Redis compatibility version (database): 6.0.16
</li>
<li>
Minimum Redis Enterprise Software version (cluster): 6.2.8
</li>
</ul>
<h2 id="v2621-august-2024">
v2.6.21 (August 2024)
</h2>
<p>
This is a maintenance release for RediSearch 2.6
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<ul>
<li>
Bug fixes:
<ul>
<li>
<a href="https://github.com/redisearch/redisearch/pull/4944">
#4944
</a>
Adjusting the module configuration to avoid routing overload on the first shard in a clustered database (MOD-7505)
</li>
<li>
<a href="https://github.com/redisearch/redisearch/pull/4897">
#4897
</a>
-
<code>
FT.AGGREGATE
</code>
with
<code>
VERBATIM
</code>
option is not handled by the shards in cluster mode (MOD-7463)
</li>
<li>
<a href="https://github.com/redisearch/redisearch/pull/4918">
#4918
</a>
- Union query, similar to
<code>
"is|the"
</code>
, starting with 2
<a href="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/">
stopwords
</a>
could cause a crash (MOD-7495)
</li>
<li>
<a href="https://github.com/redisearch/redisearch/pull/4919">
#4919
</a>
- Counting twice the field statistics at the
<code>
#search
</code>
section of an
<code>
INFO
</code>
response (MOD-7339)
</li>
<li>
<a href="https://github.com/redisearch/redisearch/pull/4923">
#4923
</a>
- Loop when using the wildcard
<code>
w'term'
</code>
and prefix/infix/suffix pattern
<code>
'ter*'
</code>
, causing the shard to restart (MOD-7453)
</li>
<li>
<a href="https://github.com/redisearch/redisearch/pull/4954">
#4954
</a>
<code>
FT.PROFILE
</code>
on
<code>
AGGREGATE
</code>
numeric queries could cause a crash due to reusing the internal
<code>
CURSOR
</code>
in a large range of numeric values (MOD-7454)
</li>
</ul>
</li>
</ul>
<h2 id="v2620-july-2024">
v2.6.20 (July 2024)
</h2>
<p>
This is a maintenance release for RediSearch 2.6
</p>
<p>
Update urgency:
<code>
MODERATE
</code>
: Program an upgrade of the server, but it's not urgent.
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4755">
#4755
</a>
- Correct return the maximum value for negative values when using
<code>
MAX
</code>
reducer (MOD-7252)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4733">
#4733
</a>
- Separators ignored when escaping backslash
<code>
\
</code>
after the escaped character such as in
<code>
hello\\,world
</code>
ignoring
<code>
,
</code>
(MOD-7240)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4717">
#4717
</a>
- Sorting by multiple fields as in
<code>
SORTBY 2 @field1 @field2
</code>
was ignoring the subsequent field (MOD-7206)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4793">
#4793
</a>
- Add character validations to simple string replies and escape it when required(MOD-7258)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4769">
#4769
</a>
- Indicate which value is missing on the error message at the aggregation pipeline (MOD-7201)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4746">
#4746
</a>
-
<code>
GROUPBY
</code>
recursion cleanup (MOD-7245)
</li>
</ul>
</li>
</ul>
<h2 id="v2619-june-2024">
v2.6.19 (June 2024)
</h2>
<p>
This is a maintenance release for RediSearch 2.6
</p>
<p>
Update urgency:
<code>
MODERATE
</code>
: Program an upgrade of the server, but it's not urgent.
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4616">
#4616
</a>
Shards become unresponsive when using FT.AGGREGATE with APPLY 'split(...)' (MOD-6759)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4557">
#4557
</a>
FT.EXPLAIN returns additional } when querying using wildcards (MOD-6768)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4647">
#4647
</a>
FT.DROPINDEX with DD flag deleted keys in one AA cluster but not the others (MOD-1855)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4599">
#4599
</a>
Report additional memory consumed by the TAG and TEXT tries (MOD-5902)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4688">
#4688
</a>
Add missing FT.INFO fields when used within a cluster (MOD-6920)
</li>
</ul>
</li>
</ul>
<h2 id="v2618-april-2024">
v2.6.18 (April 2024)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
LOW
</code>
: No need to upgrade unless there are new features you want to use.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4557">
#4557
</a>
Additional "
<code>
}
</code>
" on wildcards replies for
<code>
FT.EXPLAIN
</code>
(MOD-6768)
</li>
</ul>
</li>
</ul>
<h2 id="v2617-april-2024">
v2.6.17 (April 2024)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4524">
#4524
</a>
<code>
FT.CURSOR READ
</code>
in a numeric query causing a crash (MOD-6597)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4543">
#4543
</a>
<code>
FT.SEARCH
</code>
accessing an inexistent memory address causes a crash if using deprecated
<code>
FT.ADD
</code>
command (MOD-6599)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4535">
#4535
</a>
<code>
FT.PROFILE
</code>
with incorrect arguments could cause a crash on cluster setup (MOD-6791)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4540">
#4540
</a>
Unfree memory from an existing RDB while re-indexing loading a new RDB could cause a crash (MOD-6831, 6810)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4485">
#4485
</a>
Some parameter settings using just prefixes instead of full values were working (MOD-6709)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4502">
#4502
</a>
Handle error properly when trying to execute Search commands on cluster setup as part of
<code>
MULTI ... EXEC
</code>
or LUA script (MOD-6541)
</li>
</ul>
</li>
</ul>
<h2 id="v2616-march-2024">
v2.6.16 (March 2024)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</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/RediSearch/RediSearch/pull/4477">
#4477
</a>
Split
<code>
INFIX
</code>
and
<code>
SUFFIX
</code>
report on
<code>
FT.EXPLAIN
</code>
and
<code>
FT.EXPLAINCLI
</code>
(MOD-6186)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4468">
#4468
</a>
Memory leak upon suffix query for a
<code>
TAG
</code>
indexed with
<code>
WITHSUFFIXTRIE
</code>
(MOD-6644)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4407">
#4407
</a>
Clustered
<code>
FT.SEARCH
</code>
hangs forever without replying when an invalid topology is found (MOD-6557)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4359">
#4359
</a>
Searching for a synonym will iterate in the same group multiple times, causing a performance hit (MOD-6490)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4310">
#4310
</a>
Memory tracking on cluster setups causing high memory usage and potentially Out-of-Memory (MOD-6123, MOD-5639)
</li>
</ul>
</li>
</ul>
<h2 id="v2615-december-2023">
v2.6.15 (December 2023)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4244">
#4244
</a>
,
<a href="https://github.com/RediSearch/RediSearch/pull/4255">
#4255
</a>
Profiling
<code>
FT.AGGREGATE
</code>
using the
<code>
WITHCURSOR
</code>
flag causes a crash due to timeout (MOD-5512)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4238">
#4238
</a>
Memory excessively growing on databases caused by unbalanced nodes on inverted index trie (MOD-5880, MOD-5952, MOD-6003)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3995">
#3995
</a>
<code>
FT.CURSOR READ
</code>
with geo queries causing a crash when data is updated between the cursor reads (MOD-5646)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4155">
#4155
</a>
<code>
FT.SEARCH
</code>
not responding when using TLS encryption on Amazon Linux 2 (MOD-6012)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4176">
#4176
</a>
Initialization of the maximum numeric value range leading to a better balance of the index leaf splitting (MOD-6232)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4123">
#4123
</a>
Possibly problematic index name alias check-in command multiplexing (MOD-5945)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4195">
#4195
</a>
Query optimization when predicate contains multiple
<code>
INTERSECTION
</code>
(AND) of
<code>
UNION
</code>
(OR) (MOD-5910)
</li>
</ul>
</li>
</ul>
<h2 id="v2614-november-2023">
v2.6.14 (November 2023)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
SECURITY
</code>
: There are security fixes in the release.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3783">
#3783
</a>
Broken lower and upper
<code>
APPLY
</code>
functions in
<code>
FT.AGGREGATE
</code>
on
<code>
DIALECT 3
</code>
(MOD-5041)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3823">
#3823
</a>
<code>
APPLY
</code>
or
<code>
FILTER
</code>
expression causing a leak (MOD-5751)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3899">
#3899
</a>
Connection using TLS fail on Redis (MOD-5768)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3910">
#3910
</a>
Heavy document updates causing memory growth if memory blocks weren't properly released (MOD-5181)(MOD-5757)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3928">
#3928
</a>
Queries with
<code>
WITHCURSOR
</code>
making memory growth since
<code>
CURSOR
</code>
wasn't invalidated in the shards (MOD-5580)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3946">
#3946
</a>
Vector range query could cause Out-of-Memory due to memory corruption (MOD-5791)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3972">
#3972
</a>
Adding new nodes to OSS cluster can cause a crash (MOD-5778)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3957">
#3957
</a>
After cleaning the index, the GC could corrupt unique values (MOD-5815)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/4002">
#4002
</a>
Setting a low
<code>
MAXIDLE
</code>
parameter value in
<code>
FT.AGGREGATE
</code>
causes a crash (MOD-5608)
</li>
</ul>
</li>
<li>
<p>
Security and privacy:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3844">
#3844
</a>
Limits maximum phonetic length to avoid vulnerability (MOD 5767)
</li>
</ul>
</li>
</ul>
<h2 id="v2612-july-2023">
v2.6.12 (July 2023)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3557">
#3557
</a>
<code>
TIMEOUT
</code>
configuration on
<code>
FT.AGGREGATE
</code>
query being ignored (MOD-5208)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3552">
#3552
</a>
<code>
FT.CURSOR READ
</code>
on
<code>
JSON
</code>
numeric queries not returning results (MOD-4830)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3606">
#3606
</a>
Update numeric inverted index
<code>
numEntries
</code>
avoiding excessive memory consumption (MOD-5181)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3597">
#3597
</a>
Duplicating alias as output name on
<code>
FT.AGGREGATE
</code>
reducer (
<code>
REDUCE
</code>
argument) doesn't return results (MOD-5268)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3654">
#3654
</a>
Added check for
<code>
@
</code>
prefix on
<code>
GROUPBY
</code>
fields returning an error instead of wrong results
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3628">
#3628
</a>
Background indexing scanning performance (MOD-5259)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3259">
#3259
</a>
Allow alias name beginning with
<code>
as
</code>
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3641">
#3641
</a>
Indexing sanitizing trigger in heavy data updates scenario
</li>
</ul>
</li>
</ul>
<h2 id="v269-april-2023">
v2.6.9 (April 2023)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3468">
#3468
</a>
KNN searching for 0 vectors with a filter resulted in crash (MOD-5006)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3499">
#3499
</a>
<code>
MAXSEARCHRESULTS
</code>
set to
<code>
0
</code>
causing
<code>
FT.SEARCH
</code>
to crash (MOD-5062)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3494">
#3494
</a>
Removing
<code>
MAXSEARCHRESULTS
</code>
limit causes crash on
<code>
FT.AGGREGATE
</code>
(MOD-4974)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3504">
#3504
</a>
Uninitialised vector similarity query parameter bug (MOD-5063)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3430">
#3430
</a>
Improve min-max heap structure for better readability and performance
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3450">
#3450
</a>
Display
<code>
NOHL
</code>
option in
<code>
FT.INFO
</code>
command
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3534">
#3534
</a>
Vector Similarity 0.6.1: Improve multi-value index deletion logic (
<a href="https://github.com/RedisAI/VectorSimilarity/pull/346">
#346
</a>
)
</li>
</ul>
</li>
</ul>
<h2 id="v266-march-2023">
v2.6.6 (March 2023)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</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/RediSearch/RediSearch/pull/3403">
#3403
</a>
Fix suffix and prefix matching when using
<code>
CASESENSITIVE
</code>
flag (MOD-4872)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3397">
#3397
</a>
Improve the Vecsim initial capacity default value
</li>
</ul>
</li>
</ul>
<h2 id="v265-february-2023">
v2.6.5 (February 2023)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</p>
<p>
Update urgency:
<code>
HIGH
</code>
: There is a critical bug that may affect a subset of users. Upgrade!
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3354">
#3354
</a>
Library update preventing a crash during cluster failover (MOD-4560)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3357">
#3357
</a>
Handling division by zero in expressions preventing nodes to restart (MOD-4296)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3332">
#3332
</a>
Fix wildcards
<code>
*
</code>
queries on
<code>
DIALECT 2
</code>
and
<code>
DIALECT 3
</code>
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3361">
#3361
</a>
Enable the use of IPv6 for all cluster and module communication
</li>
</ul>
</li>
</ul>
<h2 id="v264-december-2022">
v2.6.4 (December 2022)
</h2>
<p>
This is a maintenance release for RediSearch 2.6.
</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/RediSearch/RediSearch/pull/3289">
#3289
</a>
Potential crash when querying multiple fields (MOD-4639)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3279">
#3279
</a>
Potential crash when querying using wildcard
<code>
*
</code>
on TAG field (MOD-4653)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3256">
#3256
</a>
Support IPv6 on cluster set command
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3194">
#3194
</a>
Add the query dialects that are in use to
<code>
FT.INFO
</code>
and
<code>
INFO MODULE
</code>
commands (MOD-4232)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3258">
#3258
</a>
Add the module version and Redis version to
<code>
INFO MODULE
</code>
</li>
</ul>
</li>
</ul>
<h2 id="v26-ga-v263-november-2022">
v2.6 GA (v2.6.3) (November 2022)
</h2>
<p>
This is the General Availability release of RediSearch 2.6.
</p>
<h3 id="highlights">
Highlights
</h3>
<p>
This new major version introduces the ability to search using
<strong>
wildcard queries
</strong>
for TEXT and TAG fields. This enables the frequently requested feature
<strong>
suffix search
</strong>
(
<code>
*vatore
</code>
and
<code>
ant?rez
</code>
are now supported).
In addition, the 2.6 release is all about
<strong>
multi-value indexing and querying of attributes
</strong>
for any attribute type (
<a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-text">
Text
</a>
,
<a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-tag">
Tag
</a>
,
<a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-numeric">
Numeric
</a>
,
<a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-geo">
Geo
</a>
and
<a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-vector">
Vector
</a>
) defined by a
<a href="/docs/latest/develop/data-types/json/path/">
JSONPath
</a>
leading to an array or to multiple scalar values.
Lastly, this version adds support for indexing double-precision floating-point vectors and range queries from a given vector.
</p>
<h3 id="whats-new-in-26">
What's new in 2.6
</h3>
<h3 id="details">
Details
</h3>
<ul>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/2886">
#2886
</a>
Support for
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/query_syntax/#wildcard-matching">
wildcard queries
</a>
for TEXT and TAG fields, where
<ul>
<li>
<code>
?
</code>
matches any single character
</li>
<li>
<code>
*
</code>
matches zero or more characters
</li>
<li>
use
<code>
'
</code>
and
<code>
\
</code>
for escaping, other special characters are ignored
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/2932">
#2932
</a>
Optimized wildcard query support (i.e., suffix trie)
</li>
</ul>
</li>
<li>
Multi-value indexing and querying
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/2819">
#2819
</a>
,
<a href="https://github.com/RediSearch/RediSearch/pull/2947">
#2947
</a>
Multi-value text search - perform full-text search on an
<a href="/docs/latest/develop/interact/search-and-query/indexing/#index-json-arrays-as-tag">
array of strings or on a JSONPath
</a>
leading to multiple strings
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3131">
#3131
</a>
Geo
<a href="https://github.com/RediSearch/RediSearch/pull/3118">
#3118
</a>
Vector
<a href="https://github.com/RediSearch/RediSearch/pull/2985">
#2985
</a>
Numeric
<a href="https://github.com/RediSearch/RediSearch/pull/3180">
#3180
</a>
Tag
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3060">
#3060
</a>
Return JSON rather than scalars from multi-value attributes. This is enabled via Dialect 3 in order not to break existing applications.
</li>
<li>
Support indexing and querying of multi-value JSONPath attributes and/or arrays (requires JSON >2.4.1)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3182">
#3182
</a>
Support for
<code>
SORTABLE
</code>
fields on JSON in an implicit un-normalized form (UNF)
</li>
</ul>
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3156">
#3156
</a>
Vector similarity 0.5.1:
<ul>
<li>
Better space optimization selection (
<a href="https://github.com/RedisAI/VectorSimilarity/pull/175">
#175
</a>
)
</li>
<li>
Aligning index capacity with block size (
<a href="https://github.com/RedisAI/VectorSimilarity/pull/177">
#177
</a>
)
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3129">
#3129
</a>
Support FLOAT64 as vector data type
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3176">
#3176
</a>
Range query support
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3105">
#3105
</a>
Support query attributes for vector queries
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>
Bugs (since 2.6-RC1 / v2.6.1):
</p>
<ul>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3197">
#3197
</a>
Failure to create temporary indices
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/pull/3098">
#3098
</a>
Wrong return value in Geo query
</li>
<li>
<a href="https://github.com/RediSearch/RediSearch/issues/3230">
#3230
</a>
Use the correct total number of matching records
</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>
With this release, we stop supporting direct upgrades from RediSearch v1.4 and v1.6 that are End-of-Life. Such RDB files can still be upgraded to RediSearch 2.0 first.
</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">
Note:
</div>
If indexing and querying RedisJSON data structures, this version is best combined with RedisJSON 2.4 GA (v2.4.1 onwards).
</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/redisearch/redisearch-2.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>
|
https://redis.io/docs/latest/operate/rs/7.4/security/access-control/ldap/.html | <section class="prose w-full py-12 max-w-none">
<h1>
LDAP authentication
</h1>
<p class="text-lg -mt-5 mb-10">
Describes how Redis Enterprise Software integrates LDAP authentication and authorization. Also describes how to enable LDAP for your deployment of Redis Enterprise Software.
</p>
<p>
Redis Enterprise Software supports
<a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">
Lightweight Directory Access Protocol
</a>
(LDAP) authentication and authorization through its
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
role-based access controls
</a>
(RBAC). You can use LDAP to authorize access to the Cluster Manager UI and to control database access.
</p>
<p>
You can configure LDAP roles using the Redis Enterprise Cluster Manager UI or
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/ldap_mappings/">
REST API
</a>
.
</p>
<h2 id="how-it-works">
How it works
</h2>
<p>
Here's how role-based LDAP integration works:
</p>
<a href="/docs/latest/images/rs/access-control-ldap-diagram.png" sdata-lightbox="/images/rs/access-control-ldap-diagram.png">
<img alt="LDAP overview" src="/docs/latest/images/rs/access-control-ldap-diagram.png"/>
</a>
<ol>
<li>
<p>
A user signs in with their LDAP credentials.
</p>
<p>
Based on the LDAP configuration details, the username is mapped to an LDAP Distinguished Name.
</p>
</li>
<li>
<p>
A simple
<a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Bind_(authenticate)">
LDAP bind request
</a>
is attempted using the Distinguished Name and the password. The sign-in fails if the bind fails.
</p>
</li>
<li>
<p>
Obtain the user’s LDAP group memberships.
</p>
<p>
Using configured LDAP details, obtain a list of the user’s group memberships.
</p>
</li>
<li>
<p>
Compare the user’s LDAP group memberships to those mapped to local roles.
</p>
</li>
<li>
<p>
Determine if one of the user's groups is authorized to access the target resource. If so, the user is granted the level of access authorized to the role.
</p>
</li>
</ol>
<p>
To access the Cluster Manager UI, the user needs to belong to an LDAP group mapped to an administrative role.
</p>
<p>
For database access, the user needs to belong to an LDAP group mapped to a role listed in the database’s access control list (ACL). The rights granted to the group determine the user's level of access.
</p>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
Before you enable LDAP in Redis Enterprise, you need:
</p>
<ol>
<li>
<p>
The following LDAP details:
</p>
<ul>
<li>
Server URI, including host, port, and protocol details.
</li>
<li>
Certificate details for secure protocols.
</li>
<li>
Bind credentials, including Distinguished Name, password, and (optionally) client public and private keys for certificate authentication.
</li>
<li>
Authentication query details, whether template or query.
</li>
<li>
Authorization query details, whether attribute or query.
</li>
<li>
The Distinguished Names of LDAP groups you’ll use to authorize access to Redis Enterprise resources.
</li>
</ul>
</li>
<li>
<p>
The LDAP groups that correspond to the levels of access you wish to authorize. Each LDAP group will be mapped to a Redis Enterprise access control role.
</p>
</li>
<li>
<p>
A Redis Enterprise access control role for each LDAP group. Before you enable LDAP, you need to set up
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
role-based access controls
</a>
(RBAC).
</p>
</li>
</ol>
<h2 id="enable-ldap">
Enable LDAP
</h2>
<p>
To enable LDAP:
</p>
<ol>
<li>
<p>
From
<strong>
Access Control > LDAP
</strong>
in the Cluster Manager UI, select the
<strong>
Configuration
</strong>
tab and
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/enable-role-based-ldap/">
enable LDAP access
</a>
.
</p>
<a href="/docs/latest/images/rs/access-control-ldap-panel.png" sdata-lightbox="/images/rs/access-control-ldap-panel.png">
<img alt="Enable LDAP Panel" src="/docs/latest/images/rs/access-control-ldap-panel.png"/>
</a>
</li>
<li>
<p>
Map LDAP groups to
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/map-ldap-groups-to-roles/">
access control roles
</a>
.
</p>
</li>
<li>
<p>
Update database access control lists (ACLs) to
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/update-database-acls/">
authorize role access
</a>
.
</p>
</li>
</ol>
<p>
If you already have appropriate roles, you can update them to include LDAP groups.
</p>
<h2 id="more-info">
More info
</h2>
<ul>
<li>
Enable and configure
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/enable-role-based-ldap/">
role-based LDAP
</a>
</li>
<li>
Map LDAP groups to
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/map-ldap-groups-to-roles/">
access control roles
</a>
</li>
<li>
Update database ACLs to
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/update-database-acls/">
authorize LDAP access
</a>
</li>
<li>
Learn more about Redis Enterprise Software
<a href="/docs/latest/operate/rs/7.4/security/">
security and practices
</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/operate/rs/7.4/security/access-control/ldap/"/>
<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/deployment/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Deployment
</h1>
<p class="text-lg -mt-5 mb-10">
This section lists the different ways to set up and run Redis Enterprise for Kubernetes. You can deploy on variety of Kubernetes distributions both on-prem and in the cloud via our Redis Enterprise operator for Kubernetes.
</p>
<p>
This section lists the different ways to set up and run Redis Enterprise for Kubernetes. You can deploy on variety of Kubernetes distributions both on-prem and in the cloud via our Redis Enterprise operator for Kubernetes.
</p>
<h2 id="compatibility">
Compatibility
</h2>
<p>
Before installing, check
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
to see which Redis Enterprise operator version supports your Kubernetes distribution.
</p>
<nav>
<a href="/docs/latest/operate/kubernetes/deployment/quick-start/">
Deploy Redis Enterprise Software for Kubernetes
</a>
<p>
How to install Redis Enterprise Software for Kubernetes.
</p>
<a href="/docs/latest/operate/kubernetes/deployment/openshift/">
Deploy Redis Enterprise for Kubernetes with OpenShift
</a>
<p>
A quick introduction to the steps necessary to get a Redis Enterprise cluster installed in your OpenShift Kubernetes cluster
</p>
<a href="/docs/latest/operate/kubernetes/deployment/container-images/">
Use a private registry for container images
</a>
<p>
This section details how the Redis Enterprise Software and Kubernetes operator images can be configured to be pulled from a variety of sources. This page describes how to configure alternate private repositories for images, plus some techniques for handling public repositories with rate limiting.
</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/operate/kubernetes/deployment/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Advanced concepts
</h1>
<p class="text-lg -mt-5 mb-10">
Details about query syntax, aggregation, scoring, and other search and query options
</p>
<p>
Redis Stack supports the following Redis Query Engine features. This article provides you an overview.
</p>
<h2 id="indexing-features">
Indexing features
</h2>
<ul>
<li>
Secondary indexing
</li>
<li>
Vector indexing
</li>
<li>
Index on
<a href="/docs/latest/develop/data-types/json/">
JSON
</a>
documents
</li>
<li>
Full-text indexing of multiple fields in a document
</li>
<li>
Incremental indexing without performance loss
</li>
<li>
Document deletion and updating with index garbage collection
</li>
</ul>
<h2 id="query-features">
Query features
</h2>
<ul>
<li>
Multi-field queries
</li>
<li>
Query on
<a href="/docs/latest/develop/data-types/json/">
JSON
</a>
documents
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations/">
Aggregation
</a>
</li>
<li>
Boolean queries with AND, OR, and NOT operators between subqueries
</li>
<li>
Optional query clauses
</li>
<li>
Retrieval of full document contents or only their IDs
</li>
<li>
Exact phrase search and slop-based search
</li>
<li>
Numeric filters and ranges
</li>
<li>
Geo-filtering using Redis
<a href="/docs/latest/commands/?group=geo">
geo commands
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors/">
Vector search
</a>
</li>
</ul>
<h2 id="full-text-search-features">
Full-text search features
</h2>
<ul>
<li>
<a href="/docs/latest/develop/interact/search-and-query/query/#prefix-matching">
Prefix-based searches
</a>
</li>
<li>
Field weights
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/administration/overview#auto-complete">
Auto-complete
</a>
and fuzzy prefix suggestions
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stemming/">
Stemming
</a>
-based query expansion for
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stemming#supported-languages">
many languages
</a>
using
<a href="http://snowballstem.org/">
Snowball
</a>
</li>
<li>
Support for custom functions for query expansion and scoring (see
<a href="/docs/latest/develop/interact/search-and-query/administration/extensions/">
Extensions
</a>
)
</li>
<li>
Unicode support (UTF-8 input required)
</li>
<li>
Document ranking
</li>
</ul>
<h2 id="cluster-support">
Cluster support
</h2>
<p>
The Redis Query Engine features of Redis Stack are also available for distributed databases that can scale to billions of documents and hundreds of servers.
</p>
<h2 id="supported-platforms">
Supported platforms
</h2>
<p>
Redis Stack is developed and tested on Linux and macOS on x86_64 CPUs.
</p>
<p>
Atom CPUs are not supported.
</p>
<br/>
<nav>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations/">
Aggregations
</a>
<p>
Groupings, projections, and aggregation functions
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/">
Stop words
</a>
<p>
Stop words support
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/escaping/">
Tokenization
</a>
<p>
Controlling text tokenization and escaping
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/">
Query dialects
</a>
<p>
Learn how to use query dialects
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/query_syntax/">
Query syntax
</a>
<p>
Learn how to use query syntax
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/sorting/">
Sorting by indexed fields
</a>
<p>
Support for sorting query results
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/tags/">
Tags
</a>
<p>
Details about tag fields
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/highlight/">
Highlighting
</a>
<p>
Highlighting full-text results
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/scoring/">
Scoring documents
</a>
<p>
Full-text scoring functions
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stemming/">
Stemming
</a>
<p>
Stemming support
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/synonyms/">
Synonym support
</a>
<p>
Details on synonym support with Redis Stack
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/spellcheck/">
Spellchecking
</a>
<p>
Query spelling correction support
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/phonetic_matching/">
Phonetic matching
</a>
<p>
Details about phonetic matching capabilities
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/vectors/">
Vectors
</a>
<p>
Learn how to use vector fields and perform vector searches in Redis
</p>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/chinese/">
Chinese support
</a>
<p>
Chinese support for searching and querying in Redis Stack
</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/interact/search-and-query/advanced-concepts/"/>
<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/use/keyspace/.html | <section class="prose w-full py-12">
<h1>
Keyspace
</h1>
<p class="text-lg -mt-5 mb-10">
Managing keys in Redis: Key expiration, scanning, altering and querying the key space
</p>
<p>
Redis keys are binary safe; this means that you can use any binary sequence as a
key, from a string like "foo" to the content of a JPEG file.
The empty string is also a valid key.
</p>
<p>
A few other rules about keys:
</p>
<ul>
<li>
Very long keys are not a good idea. For instance a key of 1024 bytes is a bad
idea not only memory-wise, but also because the lookup of the key in the
dataset may require several costly key-comparisons. Even when the task at hand
is to match the existence of a large value, hashing it (for example
with SHA1) is a better idea, especially from the perspective of memory
and bandwidth.
</li>
<li>
Very short keys are often not a good idea. There is little point in writing
"u1000flw" as a key if you can instead write "user:1000:followers". The latter
is more readable and the added space is minor compared to the space used by
the key object itself and the value object. While short keys will obviously
consume a bit less memory, your job is to find the right balance.
</li>
<li>
Try to stick with a schema. For instance "object-type:id" is a good
idea, as in "user:1000". Dots or dashes are often used for multi-word
fields, as in "comment:4321:reply.to" or "comment:4321:reply-to".
</li>
<li>
The maximum allowed key size is 512 MB.
</li>
</ul>
<h2 id="altering-and-querying-the-key-space">
Altering and querying the key space
</h2>
<p>
There are commands that are not defined on particular types, but are useful
in order to interact with the space of keys, and thus, can be used with
keys of any type.
</p>
<p>
For example the
<a href="/docs/latest/commands/exists/">
<code>
EXISTS
</code>
</a>
command returns 1 or 0 to signal if a given key
exists or not in the database, while the
<a href="/docs/latest/commands/del/">
<code>
DEL
</code>
</a>
command deletes a key
and associated value, whatever the value is.
</p>
<pre><code>> set mykey hello
OK
> exists mykey
(integer) 1
> del mykey
(integer) 1
> exists mykey
(integer) 0
</code></pre>
<p>
From the examples you can also see how
<a href="/docs/latest/commands/del/">
<code>
DEL
</code>
</a>
itself returns 1 or 0 depending on whether
the key was removed (it existed) or not (there was no such key with that
name).
</p>
<p>
There are many key space related commands, but the above two are the
essential ones together with the
<a href="/docs/latest/commands/type/">
<code>
TYPE
</code>
</a>
command, which returns the kind
of value stored at the specified key:
</p>
<pre><code>> set mykey x
OK
> type mykey
string
> del mykey
(integer) 1
> type mykey
none
</code></pre>
<h2 id="key-expiration">
Key expiration
</h2>
<p>
Before moving on, we should look at an important Redis feature that works regardless of the type of value you're storing: key expiration. Key expiration lets you set a timeout for a key, also known as a "time to live", or "TTL". When the time to live elapses, the key is automatically destroyed.
</p>
<p>
A few important notes about key expiration:
</p>
<ul>
<li>
They can be set both using seconds or milliseconds precision.
</li>
<li>
However the expire time resolution is always 1 millisecond.
</li>
<li>
Information about expires are replicated and persisted on disk, the time virtually passes when your Redis server remains stopped (this means that Redis saves the date at which a key will expire).
</li>
</ul>
<p>
Use the
<a href="/docs/latest/commands/expire/">
<code>
EXPIRE
</code>
</a>
command to set a key's expiration:
</p>
<pre><code>> set key some-value
OK
> expire key 5
(integer) 1
> get key (immediately)
"some-value"
> get key (after some time)
(nil)
</code></pre>
<p>
The key vanished between the two
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
calls, since the second call was
delayed more than 5 seconds. In the example above we used
<a href="/docs/latest/commands/expire/">
<code>
EXPIRE
</code>
</a>
in
order to set the expire (it can also be used in order to set a different
expire to a key already having one, like
<a href="/docs/latest/commands/persist/">
<code>
PERSIST
</code>
</a>
can be used in order
to remove the expire and make the key persistent forever). However we
can also create keys with expires using other Redis commands. For example
using
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
options:
</p>
<pre><code>> set key 100 ex 10
OK
> ttl key
(integer) 9
</code></pre>
<p>
The example above sets a key with the string value
<code>
100
</code>
, having an expire
of ten seconds. Later the
<a href="/docs/latest/commands/ttl/">
<code>
TTL
</code>
</a>
command is called in order to check the
remaining time to live for the key.
</p>
<p>
In order to set and check expires in milliseconds, check the
<a href="/docs/latest/commands/pexpire/">
<code>
PEXPIRE
</code>
</a>
and
the
<a href="/docs/latest/commands/pttl/">
<code>
PTTL
</code>
</a>
commands, and the full list of
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
options.
</p>
<h2 id="navigating-the-keyspace">
Navigating the keyspace
</h2>
<h3 id="scan">
Scan
</h3>
<p>
To incrementally iterate over the keys in a Redis database in an efficient manner, you can use the
<a href="/docs/latest/commands/scan/">
<code>
SCAN
</code>
</a>
command.
</p>
<p>
Since
<a href="/docs/latest/commands/scan/">
<code>
SCAN
</code>
</a>
allows for incremental iteration, returning only a small number of elements per call, it 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
<a href="/docs/latest/commands/scan/">
<code>
SCAN
</code>
</a>
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>
<h3 id="keys">
Keys
</h3>
<p>
Another way to iterate over the keyspace is to use the
<a href="/docs/latest/commands/keys/">
<code>
KEYS
</code>
</a>
command, but this approach should be used with care, since
<a href="/docs/latest/commands/keys/">
<code>
KEYS
</code>
</a>
will block the Redis server until all keys are returned.
</p>
<p>
<strong>
Warning
</strong>
: consider
<a href="/docs/latest/commands/keys/">
<code>
KEYS
</code>
</a>
as a command that should only be used in production
environments with extreme care.
</p>
<p>
<a href="/docs/latest/commands/keys/">
<code>
KEYS
</code>
</a>
may ruin performance when it is executed against large databases.
This command is intended for debugging and special operations, such as changing
your keyspace layout.
Don't use
<a href="/docs/latest/commands/keys/">
<code>
KEYS
</code>
</a>
in your regular application code.
If you're looking for a way to find keys in a subset of your keyspace, consider
using
<a href="/docs/latest/commands/scan/">
<code>
SCAN
</code>
</a>
or
<a href="/develop/data-types#sets">
sets
</a>
.
</p>
<p>
Supported glob-style patterns:
</p>
<ul>
<li>
<code>
h?llo
</code>
matches
<code>
hello
</code>
,
<code>
hallo
</code>
and
<code>
hxllo
</code>
</li>
<li>
<code>
h*llo
</code>
matches
<code>
hllo
</code>
and
<code>
heeeello
</code>
</li>
<li>
<code>
h[ae]llo
</code>
matches
<code>
hello
</code>
and
<code>
hallo,
</code>
but not
<code>
hillo
</code>
</li>
<li>
<code>
h[^e]llo
</code>
matches
<code>
hallo
</code>
,
<code>
hbllo
</code>
, ... but not
<code>
hello
</code>
</li>
<li>
<code>
h[a-b]llo
</code>
matches
<code>
hallo
</code>
and
<code>
hbllo
</code>
</li>
</ul>
<p>
Use
<code>
\
</code>
to escape special characters if you want to match them verbatim.
</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/use/keyspace/"/>
<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/develop/data-types/lists/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Lists in Active-Active databases
</h1>
<p class="text-lg -mt-5 mb-10">
Information about using list with an Active-Active database.
</p>
<p>
Redis lists are simply lists of strings, sorted by insertion order. It
is possible to add elements to a Redis List that push new elements to
the head (on the left) or to the tail (on the right) of the list. Redis
lists can be used to easily implement queues (using LPUSH and RPOP, for
example) and stacks (using LPUSH and LPOP, for
example).
</p>
<p>
Lists in Active-Active databases are just the same as regular Redis Lists. See the
following examples to get familiar with Lists' behavior in an
Active-Active database.
</p>
<p>
Simple Lists
example:
</p>
<table>
<thead>
<tr>
<th style="text-align:right">
<strong>
Time
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 1
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 2
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">
t1
</td>
<td style="text-align:center">
LPUSH mylist “hello”
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:right">
t2
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t3
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
LPUSH mylist “world”
</td>
</tr>
<tr>
<td style="text-align:right">
t4
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t5
</td>
<td style="text-align:center">
LRANGE mylist 0 -1 =>“world” “hello”
</td>
<td style="text-align:center">
LRANGE mylist 0 -1 => “world” “hello”
</td>
</tr>
</tbody>
</table>
<p>
<strong>
Explanation
</strong>
:
The final list contains both the "world" and "hello" elements, in that
order (Instance 2 observed "hello" when it added
"world").
</p>
<p>
Example of Lists with Concurrent
Insertions:
</p>
<table>
<thead>
<tr>
<th style="text-align:right">
<strong>
Time
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 1
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 2
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">
t1
</td>
<td style="text-align:center">
LPUSH L x
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:right">
t2
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t3
</td>
<td style="text-align:center">
LINSERT L AFTER x y1
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:right">
t4
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
LINSERT L AFTER x y2
</td>
</tr>
<tr>
<td style="text-align:right">
t5
</td>
<td style="text-align:center">
LRANGE L 0 -1 => x y1
</td>
<td style="text-align:center">
LRANGE L 0 -1 => x y2
</td>
</tr>
<tr>
<td style="text-align:right">
t6
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t7
</td>
<td style="text-align:center">
LRANGE L 0 -1 => x y1 y2
</td>
<td style="text-align:center">
LRANGE L 0 -1 => x y1 y2
</td>
</tr>
</tbody>
</table>
<p>
<strong>
Explanation
</strong>
:
Instance 1 added an element y1 after x, and then Instance 2 added element y2 after x.
The final List contains all three elements: x is the first element, after it y1 and then y2.
The Active-Active database resolves the conflict arbitrarily but applies the resolution consistently across all Active-Active database instances.
</p>
<p>
Example of Deleting a List while Pushing a New
Element:
</p>
<table>
<thead>
<tr>
<th style="text-align:right">
<strong>
Time
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 1
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 2
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">
t1
</td>
<td style="text-align:center">
LPUSH L x
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:right">
t2
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t3
</td>
<td style="text-align:center">
LRANGE L 0 -1 => x
</td>
<td style="text-align:center">
LRANGE L 0 -1 => x
</td>
</tr>
<tr>
<td style="text-align:right">
t4
</td>
<td style="text-align:center">
LPUSH L y
</td>
<td style="text-align:center">
DEL L
</td>
</tr>
<tr>
<td style="text-align:right">
t5
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t6
</td>
<td style="text-align:center">
LRANGE L 0 -1 => y
</td>
<td style="text-align:center">
LRANGE L 0 -1 => y
</td>
</tr>
</tbody>
</table>
<p>
<strong>
Explanation
</strong>
At t4 - t6, DEL deletes only observed elements. This is why L still
contains y.
</p>
<p>
Example of Popping Elements from a
List:
</p>
<table>
<thead>
<tr>
<th style="text-align:right">
<strong>
Time
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 1
</strong>
</th>
<th style="text-align:center">
<strong>
CRDB Instance 2
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">
t1
</td>
<td style="text-align:center">
LPUSH L x y z
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:right">
t2
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t3
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
RPOP L => x
</td>
</tr>
<tr>
<td style="text-align:right">
t4
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t5
</td>
<td style="text-align:center">
RPOP L => y
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:right">
t6
</td>
<td style="text-align:center">
— Sync —
</td>
<td style="text-align:center">
— Sync —
</td>
</tr>
<tr>
<td style="text-align:right">
t7
</td>
<td style="text-align:center">
RPOP L => z
</td>
<td style="text-align:center">
RPOP L => z
</td>
</tr>
</tbody>
</table>
<p>
<strong>
Explanation
</strong>
:
At t1, the operation pushes elements x, y, z to List L. At t3, the
sequential pops behave as expected from a queue. At t7, the concurrent
pop in both instances might show the same result. The instance was not
able to sync regarding the z removal so, from the point of view of each
instance, z is located in the List and can be popped. After syncing,
both lists are empty.
</p>
<p>
Be aware of the behavior of Lists in Active-Active databases when using List as a stack
or queue. As seen in the above example, two parallel RPOP operations
performed by two different Active-Active database instances can get the same element in
the case of a concurrent operation. Lists in Active-Active databases guarantee that each
element is POP-ed at least once, but cannot guarantee that each
element is POP-ed only once. Such behavior should be taken into
account when, for example, using Lists in Active-Active databases as building blocks for
inter-process communication systems.
</p>
<p>
In that case, if the same element cannot be handled twice by the
applications, it's recommended that the POP operations be performed by
one Active-Active database instance, whereas the PUSH operations can be performed by
multiple instances.
</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/databases/active-active/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/data-types/probabilistic/bloom-filter/.html | <section class="prose w-full py-12">
<h1>
Bloom filter
</h1>
<p class="text-lg -mt-5 mb-10">
Bloom filters are a probabilistic data structure that checks for presence of an element in a set
</p>
<p>
A Bloom filter is a probabilistic data structure in Redis Stack that enables you to check if an element is present in a set using a very small memory space of a fixed size.
</p>
<p>
Instead of storing all of the elements in the set, Bloom Filters store only the elements' hashed representation, thus sacrificing some precision. The trade-off is that Bloom Filters are very space-efficient and fast.
</p>
<p>
A Bloom filter can guarantee the absence of an element from a set, but it can only give an estimation about its presence. So when it responds that an element is not present in a set (a negative answer), you can be sure that indeed is the case. But one out of every N positive answers will be wrong. Even though it looks unusual at a first glance, this kind of uncertainty still has its place in computer science. There are many cases out there where a negative answer will prevent more costly operations, for example checking if a username has been taken, if a credit card has been reported as stolen, if a user has already seen an ad and much more.
</p>
<h2 id="use-cases">
Use cases
</h2>
<p>
<strong>
Financial fraud detection (finance)
</strong>
</p>
<p>
This application answers the question, "Has the user paid from this location before?", thus checking for suspicious activity in their users' shopping habits.
</p>
<p>
Use one Bloom filter per user, checked for every transaction. Provide an extremely fast response (local latency). Replicate in different regions in case the user moves. Prevent decreasing performance with scale.
</p>
<p>
Using Redis Stack's Bloom filter for this type of application provides these benefits:
</p>
<ul>
<li>
Fast transaction completion
</li>
<li>
Decreased possibility for transaction to break in case of network partitions (connection needs to be kept open for a shorter time)
</li>
<li>
Extra layer of security for both credit card owners and retailers
</li>
</ul>
<p>
Other questions a Bloom filter can help answer in the finance industry are:
</p>
<ul>
<li>
Has the user ever made purchases in this category of products/services?
</li>
<li>
Do I need to skip some security steps when the user is buying with a vetted online shop (big retailers like Amazon, Apple app store...)?
</li>
<li>
Has this credit card been reported as lost/stolen? An additional benefit of using a Bloom filter in the last case is that financial organizations can exchange their lists of stolen/blocked credit card numbers without revealing the numbers themselves.
</li>
</ul>
<p>
<strong>
Ad placement (retail, advertising)
</strong>
</p>
<p>
This application answers these questions:
</p>
<ul>
<li>
Has the user already seen this ad?
</li>
<li>
Has the user already bought this product?
</li>
</ul>
<p>
Use a Bloom filter for every user, storing all bought products. The recommendation engine suggests a new product and checks if the product is in the user's Bloom filter.
</p>
<ul>
<li>
If no, the ad is shown to the user and is added to the Bloom filter.
</li>
<li>
If yes, the process restarts and repeats until it finds a product that is not present in the filter.
</li>
</ul>
<p>
Using Redis Stack's Bloom filter for this type of application provides these benefits:
</p>
<ul>
<li>
Cost efficient way to a customized near real-time experience
</li>
<li>
No need to invest in expensive infrastructure
</li>
</ul>
<p>
<strong>
Check if a username is taken (SaaS, content publishing platforms)
</strong>
</p>
<p>
This application answers this question: Has this username/email/domain name/slug already been used?
</p>
<p>
Use a Bloom filter for every username that has signed up. A new user types in the desired username. The app checks if the username exists in the Bloom filter.
</p>
<ul>
<li>
If no, the user is created and the username is added to the Bloom filter.
</li>
<li>
If yes, the app can decide to either check the main database or reject the username.
</li>
</ul>
<p>
The query time stays the same at scale.
</p>
<p>
Using Redis Stack's Bloom filter for this type of application provides these benefits:
</p>
<ul>
<li>
Very fast and efficient way to do a common operation
</li>
<li>
No need to invest in expensive infrastructure
</li>
</ul>
<h2 id="example">
Example
</h2>
<p>
Consider a bike manufacturer that makes a million different kinds of bikes and you'd like to avoid using a duplicate model name in new models. A Bloom filter can be used to detect duplicates. In the example that follows, you'll create a filter with space for a million entries and with a 0.1% error rate. Add one model name and check if it exists. Then add multiple model names and check if they exist.
</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="bf_tutorial-stepbloom">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_bf_tutorial-stepbloom" name="bf_tutorial-stepbloom" 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_bf_tutorial-stepbloom" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-bf_tutorial-stepbloom" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_bf_tutorial-stepbloom" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> BF.RESERVE bikes:models 0.001 1000000
</span></span><span class="line hl"><span class="cl">OK
</span></span><span class="line hl"><span class="cl">> BF.ADD bikes:models "Smoky Mountain Striker"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> BF.EXISTS bikes:models "Smoky Mountain Striker"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> BF.MADD bikes:models "Rocky Mountain Racer" "Cloudy City Cruiser" "Windy City Wippet"
</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) 1
</span></span><span class="line hl"><span class="cl">> BF.MEXISTS bikes:models "Rocky Mountain Racer" "Cloudy City Cruiser" "Windy City Wippet"
</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) 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_bf_tutorial-stepbloom')" 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_bf_tutorial-stepbloom" name="bf_tutorial-stepbloom" 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_bf_tutorial-stepbloom" title="Open example">
Python
</label>
<div aria-labelledby="tab-bf_tutorial-stepbloom" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_bf_tutorial-stepbloom" 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 Bloom filter doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/bloom-filter/
</span></span></span><span class="line"><span class="cl"><span class="s2">"""</span>
</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">bf</span><span class="p">()</span><span class="o">.</span><span class="n">reserve</span><span class="p">(</span><span class="s2">"bikes:models"</span><span class="p">,</span> <span class="mf">0.01</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">res1</span><span class="p">)</span> <span class="c1"># >>> True</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">bf</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:models"</span><span class="p">,</span> <span class="s2">"Smoky Mountain Striker"</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"># >>> True</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">bf</span><span class="p">()</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"bikes:models"</span><span class="p">,</span> <span class="s2">"Smoky Mountain Striker"</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"># >>> True</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">bf</span><span class="p">()</span><span class="o">.</span><span class="n">madd</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:models"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"Rocky Mountain Racer"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"Cloudy City Cruiser"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"Windy City Wippet"</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="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># >>> [True, True, True]</span>
</span></span><span class="line hl"><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">bf</span><span class="p">()</span><span class="o">.</span><span class="n">mexists</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:models"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"Rocky Mountain Racer"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"Cloudy City Cruiser"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s2">"Windy City Wippet"</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="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># >>> [True, True, True]</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_bf_tutorial-stepbloom')" 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_bf_tutorial-stepbloom" 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_bloom.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_bf_tutorial-stepbloom" name="bf_tutorial-stepbloom" 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_bf_tutorial-stepbloom" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-bf_tutorial-stepbloom" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_bf_tutorial-stepbloom" 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="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></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">bf</span><span class="p">.</span><span class="nx">reserve</span><span class="p">(</span><span class="s1">'bikes:models'</span><span class="p">,</span> <span class="mf">0.01</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="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">// >>> 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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">bf</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:models'</span><span class="p">,</span> <span class="s1">'Smoky Mountain Striker'</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">// >>> 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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">bf</span><span class="p">.</span><span class="nx">exists</span><span class="p">(</span><span class="s1">'bikes:models'</span><span class="p">,</span> <span class="s1">'Smoky Mountain Striker'</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">// >>> 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">bf</span><span class="p">.</span><span class="nx">mAdd</span><span class="p">(</span><span class="s1">'bikes:models'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'Rocky Mountain Racer'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'Cloudy City Cruiser'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'Windy City Wippet'</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">res4</span><span class="p">);</span> <span class="c1">// >>> [true, true, 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">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">bf</span><span class="p">.</span><span class="nx">mExists</span><span class="p">(</span><span class="s1">'bikes:models'</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'Rocky Mountain Racer'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'Cloudy City Cruiser'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'Windy City Wippet'</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">res5</span><span class="p">);</span> <span class="c1">// >>> [true, true, true]
</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_bf_tutorial-stepbloom')" 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_bf_tutorial-stepbloom" 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-bloom.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_bf_tutorial-stepbloom" name="bf_tutorial-stepbloom" 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_bf_tutorial-stepbloom" title="Open example">
Java
</label>
<div aria-labelledby="tab-bf_tutorial-stepbloom" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_bf_tutorial-stepbloom" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl">
</span></span><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">org.junit.Assert</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></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">BloomFilterExample</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></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bfReserve</span><span class="o">(</span><span class="s">"bikes:models"</span><span class="o">,</span> <span class="mf">0.01</span><span class="o">,</span> <span class="mi">1000</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">// >>> 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></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bfAdd</span><span class="o">(</span><span class="s">"bikes:models"</span><span class="o">,</span> <span class="s">"Smoky Mountain Striker"</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">// >>> 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">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bfExists</span><span class="o">(</span><span class="s">"bikes:models"</span><span class="o">,</span> <span class="s">"Smoky Mountain Striker"</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">// >>> 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"><</span><span class="n">Boolean</span><span class="o">></span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bfMAdd</span><span class="o">(</span><span class="s">"bikes:models"</span><span class="o">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Rocky Mountain Racer"</span><span class="o">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Cloudy City Cruiser"</span><span class="o">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Windy City Wippet"</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">// >>> [True, True, 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"><</span><span class="n">Boolean</span><span class="o">></span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bfMExists</span><span class="o">(</span><span class="s">"bikes:models"</span><span class="o">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Rocky Mountain Racer"</span><span class="o">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Cloudy City Cruiser"</span><span class="o">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Windy City Wippet"</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">// >>> [True, True, True]
</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 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_bf_tutorial-stepbloom')" 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_bf_tutorial-stepbloom" 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/BloomFilterExample.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_bf_tutorial-stepbloom" name="bf_tutorial-stepbloom" 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_bf_tutorial-stepbloom" title="Open example">
Go
</label>
<div aria-labelledby="tab-bf_tutorial-stepbloom" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_bf_tutorial-stepbloom" 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_bloom</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span 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">BFReserve</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:models"</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">,</span> <span class="mi">1000</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">// >>> 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">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">BFAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:models"</span><span class="p">,</span> <span class="s">"Smoky Mountain Striker"</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">// >>> 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">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">BFExists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:models"</span><span class="p">,</span> <span class="s">"Smoky Mountain Striker"</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">// >>> 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">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">BFMAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:models"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Rocky Mountain Racer"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Cloudy City Cruiser"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Windy City Wippet"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [true true 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">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">BFMExists</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:models"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Rocky Mountain Racer"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Cloudy City Cruiser"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Windy City Wippet"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <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">// >>> [true true true]
</span></span></span><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_bf_tutorial-stepbloom')" 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_bf_tutorial-stepbloom" 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/bf_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_bf_tutorial-stepbloom" name="bf_tutorial-stepbloom" 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_bf_tutorial-stepbloom" title="Open example">
C#
</label>
<div aria-labelledby="tab-bf_tutorial-stepbloom" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_bf_tutorial-stepbloom" 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.RedisStackCommands</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">Bf_tutorial</span>
</span></span><span class="line"><span 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">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BF</span><span class="p">().</span><span class="n">Reserve</span><span class="p">(</span><span class="s">"bikes:models"</span><span class="p">,</span> <span class="m">0.01</span><span class="p">,</span> <span class="m">1000</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">// >>> 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">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BF</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:models"</span><span class="p">,</span> <span class="s">"Smoky Mountain Striker"</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">// >>> 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">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BF</span><span class="p">().</span><span class="n">Exists</span><span class="p">(</span><span class="s">"bikes:models"</span><span class="p">,</span> <span class="s">"Smoky Mountain Striker"</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">// >>> 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">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BF</span><span class="p">().</span><span class="n">MAdd</span><span class="p">(</span><span class="s">"bikes:models"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]{</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Rocky Mountain Racer"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Cloudy City Cruiser"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Windy City Wippet"</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="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">res4</span><span class="p">));</span> <span class="c1">// >>> True, True, 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">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">BF</span><span class="p">().</span><span class="n">MExists</span><span class="p">(</span><span class="s">"bikes:models"</span><span class="p">,</span> <span class="k">new</span> <span class="n">RedisValue</span><span class="p">[]{</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Rocky Mountain Racer"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Cloudy City Cruiser"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"Windy City Wippet"</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="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">res5</span><span class="p">));</span> <span class="c1">// >>> True, True, True</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bloom' 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_bf_tutorial-stepbloom')" 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_bf_tutorial-stepbloom" 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/Bf_tutorial.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: there is always a chance that even with just a few items, there could be a false positive, meaning an item could "exist" even though it has not been explicitly added to the Bloom filter. For a more in depth understanding of the probabilistic nature of a Bloom filter, check out the blog posts linked at the bottom of this page.
</p>
<h2 id="reserving-bloom-filters">
Reserving Bloom filters
</h2>
<p>
With Redis Stack's Bloom filters most of the sizing work is done for you:
</p>
<pre tabindex="0"><code>BF.RESERVE {key} {error_rate} {capacity} [EXPANSION expansion] [NONSCALING]
</code></pre>
<h4 id="1-false-positives-rate-error_rate">
1. False positives rate (
<code>
error_rate
</code>
)
</h4>
<p>
The rate is a decimal value between 0 and 1. For example, for a desired false positive rate of 0.1% (1 in 1000), error_rate should be set to 0.001.
</p>
<h4 id="2-expected-capacity-capacity">
2. Expected capacity (
<code>
capacity
</code>
)
</h4>
<p>
This is the number of elements you expect having in your filter in total and is trivial when you have a static set but it becomes more challenging when your set grows over time. It's important to get the number right because if you
<strong>
oversize
</strong>
- you'll end up wasting memory. If you
<strong>
undersize
</strong>
, the filter will fill up and a new one will have to be stacked on top of it (sub-filter stacking). In the cases when a filter consists of multiple sub-filters stacked on top of each other latency for adds stays the same, but the latency for presence checks increases. The reason for this is the way the checks work: a regular check would first be performed on the top (latest) filter and if a negative answer is returned the next one is checked and so on. That's where the added latency comes from.
</p>
<h4 id="3-scaling-expansion">
3. Scaling (
<code>
EXPANSION
</code>
)
</h4>
<p>
Adding an element to a Bloom filter never fails due to the data structure "filling up". Instead the error rate starts to grow. To keep the error close to the one set on filter initialisation - the Bloom filter will auto-scale, meaning when capacity is reached an additional sub-filter will be created.
<br/>
The size of the new sub-filter is the size of the last sub-filter multiplied by
<code>
EXPANSION
</code>
. If the number of elements to be stored in the filter is unknown, we recommend that you use an expansion of 2 or more to reduce the number of sub-filters. Otherwise, we recommend that you use an expansion of 1 to reduce memory consumption. The default expansion value is 2.
</p>
<p>
The filter will keep adding more hash functions for every new sub-filter in order to keep your desired error rate.
</p>
<p>
Maybe you're wondering "Why would I create a smaller filter with a high expansion rate if I know I'm going to scale anyway?"; the answer is: for cases where you need to keep many filters (let's say a filter per user, or per product) and most of them will stay small, but some with more activity will have to scale.
</p>
<h4 id="4-nonscaling">
4.
<code>
NONSCALING
</code>
</h4>
<p>
If you know you're not going to scale use the
<code>
NONSCALING
</code>
flag because that way the filter will use one hash function less. Just remember that if you ever do reach the initially assigned capacity - your error rate will start to grow.
</p>
<h3 id="total-size-of-a-bloom-filter">
Total size of a Bloom filter
</h3>
<p>
The actual memory used by a Bloom filter is a function of the chosen error rate:
</p>
<pre tabindex="0"><code>bits_per_item = -log(error)/ln(2)
memory = capacity * bits_per_item
memory = capacity * (-log(error)/ln(2))
</code></pre>
<ul>
<li>
1% error rate requires 10.08 bits per item
</li>
<li>
0.1% error rate requires 14.4 bits per item
</li>
<li>
0.01% error rate requires 20.16 bits per item
</li>
</ul>
<p>
Just as a comparison, when using a Redis set for membership testing the memory needed is:
</p>
<pre tabindex="0"><code>memory_with_sets = capacity*(192b + value)
</code></pre>
<p>
For a set of IP addresses, for example, we would have around 40 bytes (320 bits) per element, which is considerably higher than the 20 bits per element we need for a Bloom filter with 0.01% precision.
</p>
<h2 id="bloom-vs-cuckoo-filters">
Bloom vs. Cuckoo filters
</h2>
<p>
Bloom filters typically exhibit better performance and scalability when inserting
items (so if you're often adding items to your dataset, then a Bloom filter may be ideal).
Cuckoo filters are quicker on check operations and also allow deletions.
</p>
<h2 id="performance">
Performance
</h2>
<p>
Insertion in a Bloom filter is O(K), where
<code>
k
</code>
is the number of hash functions.
</p>
<p>
Checking for an element is O(K) or O(K*n) for stacked filters, where n is the number of stacked filters.
</p>
<h2 id="academic-sources">
Academic sources
</h2>
<ul>
<li>
<a href="http://www.dragonwins.com/domains/getteched/bbc/literature/Bloom70.pdf">
Space/Time Trade-offs in Hash Coding with Allowable Errors
</a>
by Burton H. Bloom.
</li>
<li>
<a href="https://gsd.di.uminho.pt/members/cbm/ps/dbloom.pdf">
Scalable Bloom Filters
</a>
</li>
</ul>
<h2 id="references">
References
</h2>
<h3 id="webinars">
Webinars
</h3>
<ol>
<li>
<a href="https://youtu.be/dq-0xagF7v8?t=102">
Probabilistic Data Structures - The most useful thing in Redis you probably aren't using
</a>
</li>
</ol>
<h3 id="blog-posts">
Blog posts
</h3>
<ol>
<li>
<a href="https://docs.redis.com/latest/modules/redisbloom/redisbloom-quickstart/">
RedisBloom Quick Start Tutorial
</a>
</li>
<li>
<a href="https://docs.redis.com/latest/modules/redisbloom/">
Developing with Bloom Filters
</a>
</li>
<li>
<a href="https://redis.com/redis-enterprise/redis-bloom/">
RedisBloom on Redis Enterprise
</a>
</li>
<li>
<a href="https://redis.com/blog/redis-redisbloom-bloom-filters/">
Probably and No: Redis, RedisBloom, and Bloom Filters
</a>
</li>
<li>
<a href="https://redis.com/blog/rebloom-bloom-filter-datatype-redis/">
RedisBloom – Bloom Filter Datatype for Redis
</a>
</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/develop/data-types/probabilistic/bloom-filter/"/>
<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/readwrite/.html | <section class="prose w-full py-12">
<h1 class="command-name">
READWRITE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">READWRITE</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>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@connection
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Disables read queries for a connection to a Redis Cluster replica node.
</p>
<p>
Read queries against a Redis Cluster replica node are disabled by default,
but you can use the
<a href="/docs/latest/commands/readonly/">
<code>
READONLY
</code>
</a>
command to change this behavior on a per-
connection basis. The
<code>
READWRITE
</code>
command resets the readonly mode flag
of a connection back to readwrite.
</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/readwrite/"/>
<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/debuginfo/node/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Current node debug info requests
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the Redis Enterprise Software REST API debuginfo/node requests.
</p>
<div class="banner-article rounded-md" style="background-color: ">
<p>
This REST API path is deprecated as of Redis Enterprise Software version 7.4.2. Use the new path
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/nodes/debuginfo/">
<code>
/v1/nodes/debuginfo
</code>
</a>
instead.
</p>
</div>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-debuginfo-node">
GET
</a>
</td>
<td>
<code>
/v1/debuginfo/node
</code>
</td>
<td>
Get debug info for the current node
</td>
</tr>
</tbody>
</table>
<h2 id="get-debuginfo-node">
Get debug info for current node
</h2>
<pre><code>GET /v1/debuginfo/node
</code></pre>
<p>
Downloads a tar file that contains debug info for the current node.
</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_debugging_info">
view_debugging_info
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /debuginfo/node
</code></pre>
<h3 id="get-response">
Response
</h3>
<p>
Downloads the debug info in a tar file called
<code>
filename.tar.gz
</code>
. Extract the files from the tar file to access the debug info.
</p>
<h4 id="response-headers">
Response headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Content-Type
</td>
<td>
application/x-gzip
</td>
<td>
Media type of request/response body
</td>
</tr>
<tr>
<td>
Content-Length
</td>
<td>
653350
</td>
<td>
Length of the response body in octets
</td>
</tr>
<tr>
<td>
Content-Disposition
</td>
<td>
attachment; filename=debuginfo.tar.gz
</td>
<td>
Display response in browser or download as attachment
</td>
</tr>
</tbody>
</table>
<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>
Success.
</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>
Failed to get debug info.
</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/debuginfo/node/"/>
<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/import-data/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Import data into a database
</h1>
<p>
You can import an existing dataset into your Redis Cloud instance from an existing Redis server or an RDB file.
</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>
Expired keys are not imported.
As a result, the number of keys in the source and destination databases can be different after the import is complete.
</div>
</div>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
In preparation, make certain the Redis version of the source database is compatible with the database where the data will be imported.
</p>
<h2 id="redis-server">
Import from a Redis server
</h2>
<p>
To import a dataset from any publicly available Redis server:
</p>
<ol>
<li>
Select
<strong>
Databases
</strong>
from the Redis Cloud console menu and then select the target database from the database list.
</li>
<li>
In the
<strong>
Danger Zone
</strong>
, select
<strong>
Import
</strong>
.
</li>
<li>
Enter the source database details:
<ul>
<li>
Source type - Select
<strong>
Redis
</strong>
.
</li>
<li>
Redis Hostname/IP Address - Enter the hostname or the public IP address of the source Redis server.
</li>
<li>
Redis port - Enter the port of the source Redis server if it is not the default value of
<code>
6379
</code>
.
</li>
<li>
Password - Enter the password, if required by the source Redis database.
</li>
</ul>
</li>
<li>
Select
<strong>
Import
</strong>
.
</li>
</ol>
<h2 id="restore-from-an-rdb-file">
Restore from an RDB file
</h2>
<p>
If you have an RDB or a compressed RDB file from a previous backup, you can restore data from that file into your Redis Cloud database.
</p>
<h3 id="via-ftp-or-http">
Via FTP or HTTP
</h3>
<p>
To import an RDB file stored on an FTP or HTTP server:
</p>
<ol>
<li>
<p>
Select
<strong>
Databases
</strong>
from the Redis Cloud console menu and then select your database from the list.
</p>
</li>
<li>
<p>
In the
<strong>
Danger Zone
</strong>
, select
<strong>
Import
</strong>
.
</p>
</li>
<li>
<p>
Enter the details for the RDB file:
</p>
<ul>
<li>
Source type - Select
<strong>
FTP
</strong>
or
<strong>
HTTP
</strong>
.
</li>
<li>
Source path - Enter the URL for the RDB file:
<code>
<protocol>://[username][:password]@hostname[:port]/[path/]filename.rdb[.gz]
</code>
</li>
</ul>
<p>
Where:
</p>
<ul>
<li>
<code>
protocol
</code>
- Server protocol: ftp, ftps, http, https
</li>
<li>
<code>
username
</code>
- Your username, if necessary
</li>
<li>
<code>
password
</code>
- Your password, if necessary
</li>
<li>
<code>
hostname
</code>
- Hostname or IP address of the server
</li>
<li>
<code>
port
</code>
- Port number of the server, if not
<code>
6379
</code>
</li>
<li>
<code>
path
</code>
- Path to the file, if necessary
</li>
<li>
<code>
filename
</code>
- Filename of the RDB file, including the
<code>
.gz
</code>
suffix if the file is compressed
</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>
If your FTP username or password contains special characters such as
<code>
@
</code>
,
<code>
\
</code>
, or
<code>
:
</code>
, you must URL encode (also known as Percent encode) these special characters. If you don't, your database may become stuck.
</div>
</div>
</li>
<li>
<p>
For sharded databases with multiple RDB files, select
<strong>
Add source
</strong>
to add another RDB file.
</p>
</li>
<li>
<p>
Select
<strong>
Import
</strong>
.
</p>
</li>
</ol>
<h3 id="via-aws-s3">
Via AWS S3
</h3>
<p>
To use the Redis Cloud console to import your data, you must first share the file from the Amazon Web Services (AWS) management console.
</p>
<p>
To share and import an RDB file that is stored in an AWS Simple Storage Service (S3) bucket:
</p>
<ol>
<li>
<p>
In the
<a href="https://console.aws.amazon.com/">
AWS Management Console
</a>
, configure the bucket's
<a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html">
bucket policy
</a>
to give access to Redis Cloud:
</p>
<ol>
<li>
<p>
Use the
<strong>
Services
</strong>
menu to locate and select
<strong>
Storage
</strong>
>
<strong>
S3
</strong>
. This takes you to the Amazon S3 admin panel.
</p>
</li>
<li>
<p>
Use the
<strong>
Buckets
</strong>
list to locate and select your bucket. When the settings appear, select the
<strong>
Permissions
</strong>
tab, locate the
<strong>
Bucket policy
</strong>
section, and then click
<strong>
Edit
</strong>
.
</p>
<ul>
<li>
<p>
If there is no existing bucket policy, add the following JSON bucket policy. Replace
<code>
UNIQUE-BUCKET-NAME
</code>
with the name of your bucket.
</p>
<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">"Version"</span><span class="p">:</span> <span class="s2">"2012-10-17"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Id"</span><span class="p">:</span> <span class="s2">"MyBucketPolicy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Statement"</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">"Sid"</span><span class="p">:</span> <span class="s2">"RedisCloudBackupsAccess"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Effect"</span><span class="p">:</span> <span class="s2">"Allow"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Principal"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"AWS"</span><span class="p">:</span> <span class="s2">"arn:aws:iam::168085023892:root"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Action"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"s3:PutObject"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"s3:getObject"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"s3:DeleteObject"</span>
</span></span><span class="line"><span class="cl"> <span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Resource"</span><span class="p">:</span> <span class="s2">"arn:aws:s3:::UNIQUE-BUCKET-NAME/*"</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>
</li>
<li>
<p>
If a bucket policy already exists, add the following JSON policy statement to the list of statements. Replace
<code>
UNIQUE-BUCKET-NAME
</code>
with the name of your bucket.
</p>
<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">"Sid"</span><span class="p">:</span> <span class="s2">"RedisCloudBackupsAccess"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Effect"</span><span class="p">:</span> <span class="s2">"Allow"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Principal"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"AWS"</span><span class="p">:</span> <span class="s2">"arn:aws:iam::168085023892:root"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Action"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"s3:PutObject"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"s3:getObject"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"s3:DeleteObject"</span>
</span></span><span class="line"><span class="cl"> <span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Resource"</span><span class="p">:</span> <span class="s2">"arn:aws:s3:::UNIQUE-BUCKET-NAME/*"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
</li>
</ul>
</li>
<li>
<p>
Save your changes.
</p>
</li>
<li>
<p>
If the bucket is encrypted using
<a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html">
SSE-KMS
</a>
, add the following statement to your
<a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying.html">
key policy
</a>
. If you do not have a key policy, see
<a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-overview.html">
Creating a key policy
</a>
. Replace
<code>
UNIQUE-BUCKET-NAME
</code>
with the name of your bucket and
<code>
CUSTOM-KEY-ARN
</code>
with your key's
<a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html">
Amazon Resource Name (ARN)
</a>
.
</p>
<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">"Sid"</span><span class="p">:</span> <span class="s2">"Allow use of the key"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Effect"</span><span class="p">:</span> <span class="s2">"Allow"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Principal"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"AWS"</span><span class="p">:</span> <span class="s2">"arn:aws:iam::168085023892:root"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Action"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"kms:Encrypt"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"kms:Decrypt"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"kms:ReEncrypt*"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"kms:GenerateDataKey*"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"kms:DescribeKey"</span>
</span></span><span class="line"><span class="cl"> <span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"Resource"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"arn:aws:s3:::UNIQUE-BUCKET-NAME/*"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"CUSTOM-KEY-ARN"</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>
</li>
</ol>
</li>
<li>
<p>
In the
<a href="https://cloud.redis.io/">
Redis Cloud console
</a>
, select the target database from the database list.
</p>
</li>
<li>
<p>
In the
<strong>
Danger Zone
</strong>
, select
<strong>
Import
</strong>
.
</p>
</li>
<li>
<p>
Enter the details for the RDB file:
</p>
<ul>
<li>
<p>
Source type - Select
<strong>
AWS S3
</strong>
.
</p>
</li>
<li>
<p>
Source path - Enter the URL for the RDB file:
<code>
s3://bucketname/[path/]filename.rdb[.gz]
</code>
</p>
<p>
Where:
</p>
<ul>
<li>
<code>
bucketname
</code>
- Name of the S3 bucket
</li>
<li>
<code>
path
</code>
- Path to the file, if necessary
</li>
<li>
<code>
filename
</code>
- Filename of the RDB file, including the .gz suffix if the file is compressed
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>
For sharded databases with multiple RDB files, select
<strong>
Add source
</strong>
to add another RDB file.
</p>
</li>
<li>
<p>
Select
<strong>
Import
</strong>
.
</p>
</li>
</ol>
<h3 id="via-google-cloud-storage">
Via Google Cloud Storage
</h3>
<p>
To use the Redis Cloud console to import your data, you must first share the file from the Google Cloud console.
</p>
<p>
To share and import an RDB file that is stored in a Google Cloud Storage bucket:
</p>
<ol>
<li>
<p>
In the Google Cloud Storage bucket, edit the file's Access Control List to give read access to Redis Cloud:
</p>
<ol>
<li>
Select
<strong>
Edit access
</strong>
in the RDB file menu.
</li>
<li>
Select
<strong>
Add item
</strong>
.
</li>
<li>
Enter the user details and access:
<ul>
<li>
In the Entity field of the new item, select
<strong>
User
</strong>
.
</li>
<li>
In the Name field of the new item, enter:
<code>
[email protected]
</code>
</li>
<li>
In the Access field of the new item, select
<strong>
Reader
</strong>
.
</li>
</ul>
</li>
<li>
Select
<strong>
Save
</strong>
.
</li>
</ol>
<p>
For more info, see
<a href="https://cloud.google.com/storage/docs/access-control/create-manage-lists#set-an-acl">
Set ACLs
</a>
.
</p>
</li>
<li>
<p>
In the
<a href="https://cloud.redis.io/">
Redis Cloud console
</a>
, select the target database from the database list.
</p>
</li>
<li>
<p>
In the
<strong>
Danger Zone
</strong>
, select
<strong>
Import
</strong>
.
</p>
</li>
<li>
<p>
Enter the details for the RDB file:
</p>
<ul>
<li>
<p>
Source type - Select
<strong>
Google Cloud Storage
</strong>
.
</p>
</li>
<li>
<p>
Source path - Enter the URL for the RDB file:
<code>
gs://bucketname/[path/]filename.rdb[.gz]
</code>
</p>
<p>
Where:
</p>
<ul>
<li>
<code>
bucketname
</code>
- Name of the GCS bucket
</li>
<li>
<code>
path
</code>
- Path to the file
</li>
<li>
<code>
filename
</code>
- Filename of the RDB file, including the .gz suffix if the file is compressed
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>
For sharded databases with multiple RDB files, select
<strong>
Add source
</strong>
to add another RDB file.
</p>
</li>
<li>
<p>
Select
<strong>
Import
</strong>
.
</p>
</li>
</ol>
<h3 id="via-azure-blob-storage-container">
Via Azure Blob Storage container
</h3>
<p>
To import an RDB file stored in a Microsoft Azure Blog storage container:
</p>
<ol>
<li>
<p>
In the Redis Cloud console, select the target database from the database list.
</p>
</li>
<li>
<p>
In the
<strong>
Danger Zone
</strong>
, select
<strong>
Import
</strong>
.
</p>
</li>
<li>
<p>
Enter the details for the RDB file:
</p>
<ul>
<li>
<p>
Source type - Select
<strong>
Azure Blob Storage
</strong>
.
</p>
</li>
<li>
<p>
Source path - Enter the URL for the RDB file:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">abs://:storage_account_access_key@storage_account_name/[container/]filename.rdb[.gz]
</span></span></code></pre>
</div>
<p>
Where:
</p>
<ul>
<li>
<code>
storage_account_access_key
</code>
- Primary access key to the storage account
</li>
<li>
<code>
storage_account_name
</code>
- Name of the storage account
</li>
<li>
<code>
url
</code>
- URL of the storage account
</li>
<li>
<code>
container
</code>
- Name of the container, if necessary
</li>
<li>
<code>
filename
</code>
- Filename of the RDB file, including the .gz suffix if the file is compressed
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>
For sharded databases with multiple RDB files, select
<strong>
Add source
</strong>
to add another RDB file.
</p>
</li>
<li>
<p>
Select
<strong>
Import
</strong>
.
</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/rc/databases/import-data/"/>
<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/ft.dictdel/.html | <section class="prose w-full py-12">
<h1 class="command-name">
FT.DICTDEL
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FT.DICTDEL dict term [term ...]
</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/interact/search-and-query">
Search 1.4.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 terms from a dictionary
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
dict
</code>
</summary>
<p>
is dictionary name.
</p>
</details>
<details open="">
<summary>
<code>
term
</code>
</summary>
<p>
term to delete from the dictionary.
</p>
</details>
<h2 id="return">
Return
</h2>
<p>
FT.DICTDEL returns an integer reply, the number of new terms that were deleted.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Delete terms from a dictionary
</b>
</summary>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> FT.DICTDEL dict foo bar <span class="s2">"hello world"</span>
</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>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ft.dictadd/">
<code>
FT.DICTADD
</code>
</a>
|
<a href="/docs/latest/commands/ft.dictdump/">
<code>
FT.DICTDUMP
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<p>
<a href="/docs/latest/develop/interact/search-and-query/">
RediSearch
</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/ft.dictdel/"/>
<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/7-2-4-releases/.html | <section class="prose w-full py-12 max-w-none">
<h1>
7.2.4 release notes
</h1>
<p class="text-lg -mt-5 mb-10">
Support for Redis Enterprise 7.2.4, platform support updates, and bug fixes.
</p>
<h2 id="highlights">
Highlights
</h2>
<p>
The primary purpose this release is supporting
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/">
Redis Enterprise 7.2.4
</a>
, which is a major Redis Enterprise Software update. As such, we reduced the scope of changes to support the underlying change of RS 7.2 and a few significant fixes.
</p>
<p>
The following are the notable changes:
</p>
<ul>
<li>
<p>
Support for
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/">
Redis Enterprise 7.2.4
</a>
</p>
<ul>
<li>
New major version of Redis, 7.2
</li>
<li>
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/#cluster-recovery-with-manually-uploaded-modules">
Changes to modules and cluster recovery
</a>
</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">
Warning:
</div>
Redis Enterprise Software 7.2.4-52 includes several issues that also effect Redis Enterprise for Kubernetes and are not listed below. Review the Redis Enterprise Software 7.2.4
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/#breaking-changes">
breaking changes
</a>
and
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/#known-limitations">
known limitations.
</a>
</div>
</div>
<h2 id="detailed-release-notes">
Detailed release notes
</h2>
<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/kubernetes/release-notes/7-2-4-releases/7-2-4-12-10-24/">
7.2.4-12 (October 2024)
</a>
</td>
<td style="text-align:left">
This is a maintenance release to support Redis Enterprise Software version 7.2.4-117.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12-08-2024/">
7.2.4-12 (August 2024)
</a>
</td>
<td style="text-align:left">
This is a maintenance release to support Redis Enterprise Software version 7.2.4-109.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12-03-24/">
7.2.4-12 (March 2024)
</a>
</td>
<td style="text-align:left">
This is a maintenance release to support Redis Enterprise Software version 7.2.4-105.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12/">
7.2.4-12 (Dec 2023)
</a>
</td>
<td style="text-align:left">
This is a maintenance release with a few enhancements/fixes on the Kubernetes product and a new Redis Enterprise container version.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-7/">
7.2.4-7 (Oct 2023)
</a>
</td>
<td style="text-align:left">
This is a minor maintenance release with a few enhancements/fixes on the Kubernetes product, and a newer Redis Enterprise container version.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-2/">
7.2.4-2 (Aug 2023)
</a>
</td>
<td style="text-align:left">
The primary purpose this release is supporting Redis Enterprise 7.2.4.
</td>
</tr>
</tbody>
</table>
<h2 id="version-changes">
Version changes
</h2>
<p>
For a list of fixes related to CVEs, see the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/">
Redis Enterprise 7.2.4 release notes
</a>
.
</p>
<h3 id="breaking-changes">
Breaking changes
</h3>
<p>
The following changes included in this release affect the upgrade process. Please read carefully before upgrading to 7.2.4-2.
</p>
<h4 id="validatingwebhookconfiguration">
ValidatingWebhookConfiguration
</h4>
<p>
Versions 6.4.2-4 and later include a new
<code>
ValidatingWebhookConfiguration
</code>
resource to replace the
<code>
redb-admission
</code>
webhook resource. To use releases 6.4.2-4 or later, delete the old webhook resource and apply the new file. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#reapply-webhook">
upgrade Redis cluster
</a>
for instructions.
</p>
<h4 id="openshift-scc">
OpenShift SCC
</h4>
<p>
Versions 6.4.2-6 and later include a new SCC (
<code>
redis-enterprise-scc-v2
</code>
) that you need to bind to your service account before upgrading. OpenShift clusters running version 6.2.12 or earlier upgrading to version 6.2.18 or later might get stuck if you skip this step. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#before-upgrading">
upgrade a Redis Enterprise cluster (REC)
</a>
for instructions.
</p>
<h3 id="deprecations">
Deprecations
</h3>
<ul>
<li>
Gesher (advanced admission control configuration support) previously deprecated, is no longer supported.
</li>
<li>
Deprecated
<code>
spec.RedisOnFlashSpec.flashStorageEngine
</code>
field for the RedisEnterpriseCluster. Use
<code>
bigStoreDriver
</code>
field to indicate storage engines going forward.
</li>
</ul>
<h3 id="supported-distributions">
Supported distributions
</h3>
<p>
The following table shows supported distributions at the time of this release. You can also find this list in
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
.
</p>
<p>
<span title="Check mark icon">
✅
</span>
Supported – This distribution is supported for this version of Redis Enterprise Software for Kubernetes.
</p>
<p>
<span title="Warning icon">
⚠️
</span>
Deprecated – This distribution is still supported for this version of Redis Enterprise Software for Kubernetes, but support will be removed in a future release.
</p>
<p>
<span title="X icon">
❌
</span>
End of life – Support for this distribution ended.
</p>
<p>
Any distribution not listed below is not supported for production workloads.
</p>
<table>
<thead>
<tr>
<th>
<strong>
Kubernetes version
</strong>
</th>
<th>
<strong>
1.22
</strong>
</th>
<th>
<strong>
1.23
</strong>
</th>
<th>
<strong>
1.24
</strong>
</th>
<th>
<strong>
1.25
</strong>
</th>
<th>
<strong>
1.26
</strong>
</th>
<th>
<strong>
1.27
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Community Kubernetes
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
</tr>
<tr>
<td>
Amazon EKS
</td>
<td>
<span title="End of life">
❌
</span>
</td>
<td>
<span title="Deprecation warning">
⚠️
</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>
Azure AKS
</td>
<td>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
</tr>
<tr>
<td>
Google GKE
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
</tr>
<tr>
<td>
Rancher 2.6
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
Rancher 2.7
</td>
<td>
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
VMware TKG 1.6
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<strong>
OpenShift version
</strong>
</td>
<td>
<strong>
4.9
</strong>
</td>
<td>
<strong>
4.10
</strong>
</td>
<td>
<strong>
4.11
</strong>
</td>
<td>
<strong>
4.12
</strong>
</td>
<td>
<strong>
4.13
</strong>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
<strong>
VMware TKGI version
</strong>
</td>
<td>
<strong>
1.13
</strong>
</td>
<td>
<strong>
1.14
</strong>
</td>
<td>
<strong>
1.15
</strong>
</td>
<td>
<strong>
1.16
</strong>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span title="X icon">
❌
</span>
</td>
<td>
<span title="Warning icon">
⚠️
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
<span title="Check mark icon">
✅
</span>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
<h2 id="known-limitations">
Known limitations
</h2>
<p>
The limitations below are specific to the Redis Enterprise for Kubernetes product. To view limitations for the supported Redis Enterprise Software version, see the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/#known-limitations">
7.2.4 release notes
</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">
Warning:
</div>
Pay particular attention to the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/#cluster-recovery-with-manually-uploaded-modules">
cluster recovery limitation
</a>
if you use manually uploaded modules.
</div>
</div>
<ul>
<li>
<p>
<strong>
Cannot upgrade or recover clusters if there are databases with manually uploaded modules (RED-107711 RED-106872)
</strong>
Contact support.
</p>
</li>
<li>
<p>
<strong>
REDBs created with versions before 6.2.10-4 will automatically upgrade modules when the cluster is upgraded (RED-106834)
</strong>
</p>
</li>
<li>
<p>
<strong>
When modifying the database suffix for an Active-Active database, while the service-rigger is in a terminating state, the services-rigger will detele and create the ingress or route resources in a loop (RED-107687)
</strong>
Wait until the services- rigger pod has finished to terminate it.
</p>
</li>
<li>
<p>
<strong>
REAADB changes might fail with "gateway timeout" errors, mostly on OpenShift (RED-103048)
</strong>
Retry the operation.
</p>
</li>
<li>
<p>
<strong>
Misleading error appears when a service creation has failed due to service already existing "
<code>
provided IP is already allocated
</code>
" (RED-100669)
</strong>
Delete the service manually.
</p>
</li>
<li>
<p>
<strong>
Existing OpenShift route during REC creation might prevent REC from starting (RED-100668)
</strong>
Delete the route manually.
</p>
</li>
<li>
<p>
<strong>
Creating two databases with the same name directly on Redis Enterprise software will cause the service to be deleted and the database will not be available (RED-99997)
</strong>
Avoid duplicating database names. Database creation via K8s has validation in place to prevent this.
</p>
</li>
<li>
<p>
<strong>
Installing the operator bundle produces warning:
<code>
Warning: would violate PodSecurity "restricted: v1.24"
</code>
(RED-97381)
</strong>
Ignore the warning. This issue is documented as benign on official Red Hat documentation.
</p>
</li>
<li>
<p>
<strong>
RERC resources must have a unique name (RED-96302)
</strong>
The string "rec-name"/"rec-namespace" must be different from all other participating clusters in the Active-Active database.
</p>
</li>
<li>
<p>
<strong>
Admission is not blocking REAADB with
<code>
shardCount
</code>
which exceeds license quota (RED-96301)
</strong>
Fix the problems with the REAADB and reapply.
</p>
</li>
<li>
<p>
<strong>
Active-Active controller only supports global database options. Configuration specific to location is not supported (RED-86490)
</strong>
</p>
</li>
<li>
<p>
<strong>
Active-Active setup removal might keep services or routes undeleted (RED-77752)
</strong>
Delete services or routes manually if you encounter this problem.
</p>
</li>
<li>
<p>
<strong>
<code>
autoUpgrade
</code>
set to
<code>
true
</code>
can cause unexpected bdb upgrades when
<code>
redisUpgradePolicy
</code>
is set to
<code>
true
</code>
(RED-72351)
</strong>
Contact support if your deployment is impacted.
</p>
</li>
<li>
<p>
<strong>
Following the previous quick start guide version causes issues with creating an REDB due to unrecognized memory field name (RED-69515)
</strong>
The workaround is to use the newer (current) revision of Deploy Redis Enterprise Software for Kubernetes.
</p>
</li>
<li>
<p>
<strong>
PVC size issues when using decimal value in spec (RED-62132)
</strong>
Make sure you use integer values for the PVC size.
</p>
</li>
<li>
<p>
<strong>
REC might report error states on initial startup (RED-61707)
</strong>
There is no workaround at this time except to ignore the errors.
</p>
</li>
<li>
<p>
<strong>
Hashicorp Vault integration - no support for Gesher (RED-55080)
</strong>
There is no workaround for this issue. Gesher support has been deprecated.
</p>
</li>
<li>
<p>
<strong>
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254)
</strong>
When REC clusters are deployed on Kubernetes clusters without synchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes.
</p>
</li>
<li>
<p>
<strong>
Deleting an OpenShift project with an REC deployed may hang (RED-47192)
</strong>
When an 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. Therefore, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Then, you can delete the project.
</p>
</li>
<li>
<p>
<strong>
Clusters must be named 'rec' in OLM-based deployments (RED-39825)
</strong>
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 (namely, "rec"). The workaround is to name the cluster "rec".
</p>
</li>
<li>
<p>
<strong>
Readiness probe incorrect on failures (RED-39300)
</strong>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on node failure.
</p>
</li>
<li>
<p>
<strong>
Internal DNS and Kubernetes DNS may have conflicts (RED-37462)
</strong>
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>
</li>
<li>
<p>
<strong>
K8s-based 5.4.10 clusters seem to negatively affect existing 5.4.6 clusters (RED-37233)
</strong>
Upgrade clusters to latest version.
</p>
</li>
<li>
<p>
<strong>
Node CPU usage is reported instead of pod CPU usage (RED-36884)
</strong>
In Kubernetes, the reported node CPU usage is the usage of the Kubernetes worker node hosting the REC pod.
</p>
</li>
<li>
<p>
<strong>
An unreachable cluster has status running (RED-32805)
</strong>
When a cluster is in an unreachable state, the state remains
<code>
running
</code>
instead of triggering an error.
</p>
</li>
<li>
<p>
<strong>
Long cluster names cause routes to be rejected (RED-25871)
</strong>
A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name exceeds 63 characters. The workaround is to limit the cluster name to 20 characters or fewer.
</p>
</li>
<li>
<p>
<strong>
Cluster CR (REC) errors are not reported after invalid updates (RED-25542)
</strong>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</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/kubernetes/release-notes/7-2-4-releases/"/>
<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/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/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/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/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/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/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/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/commands/copy/.html | <section class="prose w-full py-12">
<h1 class="command-name">
COPY
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">COPY source destination [DB destination-db] [REPLACE]</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(N) worst case for collections, where N is the number of nested items. O(1) for string values.
</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>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
This command copies the value stored at the
<code>
source
</code>
key to the
<code>
destination
</code>
key.
</p>
<p>
By default, the
<code>
destination
</code>
key is created in the logical database used by the
connection. The
<code>
DB
</code>
option allows specifying an alternative logical database
index for the destination key.
</p>
<p>
The command returns zero when the
<code>
destination
</code>
key already exists. The
<code>
REPLACE
</code>
option removes the
<code>
destination
</code>
key before copying the value to it.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>SET dolly "sheep"
COPY dolly clone
GET clone
</code></pre>
<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>
source
</em>
was copied.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
0
</code>
if
<em>
source
</em>
was not copied.
</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/copy/"/>
<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.insertnx.html | <section class="prose w-full py-12">
<h1 class="command-name">
CF.INSERTNX
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CF.INSERTNX key [CAPACITY capacity] [NOCREATE] ITEMS item [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(n * (k + i)), where n is the number of items, k is the number of sub-filters and i is maxIterations
</dd>
</dl>
<p>
Adds one or more items to a cuckoo filter if they did not exist previously, allowing the filter to be created with a custom capacity if it does not exist yet.
</p>
<p>
This command is similar to
<a href="/docs/latest/commands/cf.addnx/">
<code>
CF.ADDNX
</code>
</a>
, except that more than one item can be added and capacity can be specified.
</p>
<p>
<note>
<b>
Notes:
</b>
</note>
</p>
<ul>
<li>
This command is slower than
<a href="/docs/latest/commands/cf.insert/">
<code>
CF.INSERT
</code>
</a>
because it first checks whether each item exists.
</li>
<li>
Since
<a href="/docs/latest/commands/cf.exists/">
<code>
CF.EXISTS
</code>
</a>
can result in false positive,
<code>
CF.INSERTNX
</code>
may not add an item because it is supposedly already exist, which may be wrong.
</li>
</ul>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for a cuckoo filter to add items to.
</p>
<p>
If
<code>
key
</code>
does not exist - a new cuckoo filter is created.
</p>
</details>
<details open="">
<summary>
<code>
ITEMS item...
</code>
</summary>
<p>
One or more items to add.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
CAPACITY capacity
</code>
</summary>
<p>
Specifies the desired capacity of the new filter, if this filter does not exist yet.
</p>
<p>
If the filter already exists, then this parameter is ignored.
</p>
<p>
If the filter does not exist yet and this parameter is
<em>
not
</em>
specified, then the filter is created with the module-level default capacity which is 1024.
</p>
<p>
See
<a href="/docs/latest/commands/cf.reserve/">
<code>
CF.RESERVE
</code>
</a>
for more information on cuckoo filter capacities.
</p>
</details>
<details open="">
<summary>
<code>
NOCREATE
</code>
</summary>
<p>
If specified, prevents automatic filter creation if the filter does not exist (Instead, an error is returned).
</p>
<p>
This option is mutually exclusive with
<code>
CAPACITY
</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/#arrays">
Array reply
</a>
of
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
, where
<code>
0
</code>
means that the item's fingerprint already exists in the filter,
<code>
1
</code>
means that the item has been successfully added to the filter, and
<code>
-1
</code>
means that the item was not added because the filter is full.
</li>
<li>
[] on error (invalid arguments, wrong key type, etc.) and also when
<code>
NOCREATE
</code>
is specified and
<code>
key
</code>
does not exist.
</li>
</ul>
<h3 id="complexity">
Complexity
</h3>
<p>
O(n + i), where n is the number of
<code>
sub-filters
</code>
and i is
<code>
maxIterations
</code>
.
Adding items requires up to 2 memory accesses per
<code>
sub-filter
</code>
.
But as the filter fills up, both locations for an item might be full. The filter attempts to
<code>
Cuckoo
</code>
swap items up to
<code>
maxIterations
</code>
times.
</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> CF.INSERTNX cf CAPACITY <span class="m">1000</span> ITEMS item1 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></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> CF.INSERTNX cf CAPACITY <span class="m">1000</span> ITEMS item1 item2 item3
</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><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> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span></span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> CF.INSERTNX cf_new CAPACITY <span class="m">1000</span> NOCREATE ITEMS item1 item2
</span></span><span class="line"><span class="cl"><span class="o">(</span>error<span class="o">)</span> ERR not found</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.insertnx/"/>
<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/services_configuration/crdb_coordinator/.html | <section class="prose w-full py-12 max-w-none">
<h1>
CRDB coordinator object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the crdb_coordinator 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>
operating_mode
</td>
<td>
'disabled'
<br/>
'enabled'
</td>
<td>
Enable/disable the CRDB coordinator 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/7.4/references/rest-api/objects/services_configuration/crdb_coordinator/"/>
<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/installing-upgrading/upgrading/upgrade-active-active/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Upgrade an Active-Active database
</h1>
<p class="text-lg -mt-5 mb-10">
Upgrade an Active-Active database.
</p>
<p>
When you upgrade an
<a href="/docs/latest/operate/rs/databases/active-active/">
Active-Active (CRDB) database
</a>
, you can also upgrade the CRDB protocol version and feature version.
</p>
<h2 id="crdb-protocol-version-guidelines">
CRDB protocol version guidelines
</h2>
<p>
Redis Enterprise Software versions 5.4.2 and later use CRDB protocol version 1 to help support Active-Active features.
</p>
<p>
CRDB protocol version 1 is backward compatible, which means Redis Enterprise v5.4.2 CRDB instances can understand write operations from instances using the earlier CRDB protocol version 0.
</p>
<p>
After you upgrade one instance's CRDB protocol to version 1:
</p>
<ul>
<li>
<p>
Any instances that use CRDB protocol version 1 can receive updates from both version 1 and version 0 instances.
</p>
</li>
<li>
<p>
However, instances that still use CRDB protocol version 0 cannot receive write updates from version 1 instances.
</p>
</li>
<li>
<p>
After you upgrade an instance from CRDB protocol version 0 to version 1, it automatically receives any missing write operations.
</p>
</li>
</ul>
<p>
Follow these upgrade guidelines:
</p>
<ul>
<li>
<p>
Upgrade all instances of a specific CRDB within a reasonable time frame to avoid temporary inconsistencies between the instances.
</p>
</li>
<li>
<p>
Make sure that you upgrade all instances of a specific CRDB before you do global operations on the CRDB, such as removing instances and adding new instances.
</p>
</li>
<li>
<p>
As of v6.0.20, protocol version 0 is deprecated and support will be removed in a future version.
</p>
</li>
<li>
<p>
To avoid upgrade failures, update all Active-Active databases to protocol version 1
<em>
before
</em>
upgrading Redis Enterprise Software to v6.0.20 or later.
</p>
</li>
</ul>
<h2 id="feature-version-guidelines">
Feature version guidelines
</h2>
<p>
Starting with version 5.6.0, a new feature version (also called a
<em>
feature set version
</em>
) helps support new Active-Active features.
</p>
<p>
When you update the feature version for an Active-Active database, the feature version is updated for all database instances.
</p>
<p>
Follow these upgrade guidelines:
</p>
<ul>
<li>
<p>
As of v6.0.20, feature version 0 is deprecated and support will be removed in a future version.
</p>
</li>
<li>
<p>
To avoid upgrade failures, update all Active-Active databases to protocol version 1
<em>
before
</em>
upgrading Redis Enterprise Software to v6.0.20 or later.
</p>
</li>
</ul>
<h2 id="upgrade-active-active-database-instance">
Upgrade Active-Active database instance
</h2>
<p>
To upgrade an Active-Active database (CRDB) instance:
</p>
<ol>
<li>
<p>
<a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-cluster/">
Upgrade Redis Enterprise Software
</a>
on each node in the clusters where the Active-Active instances are located.
</p>
</li>
<li>
<p>
To see the status of your Active-Active instances, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin status
</span></span></code></pre>
</div>
<p>
The statuses of the Active-Active instances on the node can indicate:
</p>
<ul>
<li>
<code>
OLD REDIS VERSION
</code>
</li>
<li>
<code>
OLD CRDB PROTOCOL VERSION
</code>
</li>
<li>
<code>
OLD CRBD FEATURESET VERSION
</code>
</li>
</ul>
<a href="/docs/latest/images/rs/crdb-upgrade-node.png" sdata-lightbox="/images/rs/crdb-upgrade-node.png">
<img src="/docs/latest/images/rs/crdb-upgrade-node.png"/>
</a>
</li>
<li>
<p>
To upgrade each Active-Active instance and its modules, including the Redis version and CRDB protocol version, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin upgrade db <database_name <span class="p">|</span> database_ID>
</span></span></code></pre>
</div>
<p>
If the protocol version is old, read the warning message carefully and confirm.
</p>
<a href="/docs/latest/images/rs/crdb-upgrade-protocol.png" sdata-lightbox="/images/rs/crdb-upgrade-protocol.png">
<img src="/docs/latest/images/rs/crdb-upgrade-protocol.png"/>
</a>
<p>
The Active-Active instance uses the new Redis version and CRDB protocol version.
</p>
<p>
Use the
<code>
keep_crdt_protocol_version
</code>
option to upgrade the database feature version
without upgrading the CRDB protocol version.
</p>
<p>
If you use this option, make sure that you upgrade the CRDB protocol soon after with the
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/upgrade/#upgrade-db">
<code>
rladmin upgrade db
</code>
</a>
command.
</p>
<p>
You must upgrade the CRDB protocol before you update the CRDB feature set version.
</p>
</li>
<li>
<p>
If the feature set version is old, you must upgrade all of the Active-Active instances. Then, to update the feature set for each 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 update --crdb-guid <CRDB-GUID> --featureset-version yes
</span></span></code></pre>
</div>
<p>
You can retrieve the
<code>
<CRDB-GUID>
</code>
with the following command:
</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>
Look for the fully qualified domain name (CLUSTER-FDQN) of your cluster and use the associated GUID:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">CRDB-GUID NAME REPL-ID CLUSTER-FQDN
</span></span><span class="line"><span class="cl">700140c5-478e-49d7-ad3c-64d517ddc486 aatest <span class="m">1</span> aatest1.example.com
</span></span><span class="line"><span class="cl">700140c5-478e-49d7-ad3c-64d517ddc486 aatest <span class="m">2</span> aatest2.example.com
</span></span></code></pre>
</div>
</li>
<li>
<p>
Update module information in the CRDB configuration using the following command syntax:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb update --crdb-guid <guid> --default-db-config <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span><span class="s1">'{ "module_list":
</span></span></span><span class="line"><span class="cl"><span class="s1"> [
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "<module1_name>",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "<module1_version>"
</span></span></span><span class="line"><span class="cl"><span class="s1"> },
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "<module2_name>",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "<module2_version>"
</span></span></span><span class="line"><span class="cl"><span class="s1"> }
</span></span></span><span class="line"><span class="cl"><span class="s1"> ]}'</span>
</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 update --crdb-guid 82a80988-f5fe-4fa5-bca0-aef2a0fd60db --default-db-config <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span><span class="s1">'{ "module_list":
</span></span></span><span class="line"><span class="cl"><span class="s1"> [
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "search",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "2.4.6"
</span></span></span><span class="line"><span class="cl"><span class="s1"> },
</span></span></span><span class="line"><span class="cl"><span class="s1"> {
</span></span></span><span class="line"><span class="cl"><span class="s1"> "module_name": "ReJSON",
</span></span></span><span class="line"><span class="cl"><span class="s1"> "semantic_version": "2.4.5"
</span></span></span><span class="line"><span class="cl"><span class="s1"> }
</span></span></span><span class="line"><span class="cl"><span class="s1"> ]}'</span>
</span></span></code></pre>
</div>
</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/installing-upgrading/upgrading/upgrade-active-active/"/>
<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/previous-releases/k8s-6-0-6-11/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes Release Notes 6.0.6-11 (July 2020)
</h1>
<p class="text-lg -mt-5 mb-10">
Maintenance release; support RS 6.0.6-39 and various bug fixes.
</p>
<p>
The Redis Enterprise K8s 6.0.6-11 release is a
<em>
maintenance release
</em>
on top of
<a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/releases/tag/v6.0.6-6">
6.0.6-6
</a>
providing support for the latest
<a href="https://docs.redislabs.com/latest/rs/release-notes/rs-6-0-may-2020/">
Redis Enterprise Software release 6.0.6-39
</a>
and includes several bug fixes.
</p>
<h2 id="overview">
Overview
</h2>
<p>
This release of the operator provides:
</p>
<ul>
<li>
Support for the Redis Enterprise Software release 6.0.6-39
</li>
<li>
Various bug fixes
</li>
</ul>
<p>
To upgrade your deployment to this latest release, see
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/">
"Upgrade a Redis Enterprise cluster (REC) on Kubernetes"
</a>
.
</p>
<h2 id="images">
Images
</h2>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
- redislabs/redis:6.0.6-39 or redislabs/redis:6.0.6-39.rhel7-openshift
</li>
<li>
<strong>
Operator
</strong>
- redislabs/operator:6.0.6-11 or redislabs/operator:6.0.6-11.rhel7
</li>
<li>
<strong>
Services Rigger
</strong>
- redislabs/k8s-controller:6.0.6-11 or redislabs/k8s-controller:6.0.6-11.rhel7
</li>
</ul>
<h2 id="important-fixes">
Important fixes
</h2>
<ul>
<li>
The upgrade process may have failed in certain situations (i.e., with CRDB databases). We now ensure that rlutil runs at bootstrap to complete the upgrade process. (RED43635)
</li>
<li>
The example and default custom resource for the REC in the OLM now correctly uses 'nodes' (RED43847)
</li>
<li>
Fixes for security vulnerabilities in the server rigger image: upgraded to httpd 2.4.42, Kubernetes Python Client 8.0.1, and removed localhost private key. (RED42495)
</li>
<li>
A fix for an internal logging issue that caused errors to incorrectly show up on the operator log when databases are created even though the creation succeeded. (RED43336)
</li>
</ul>
<h2 id="known-limitations">
Known limitations
</h2>
<ul>
<li>
<p>
CrashLoopBackOff causes cluster recovery to be incomplete (RED33713) - When a pod status is CrashLoopBackOff and we run the cluster recovery, the process will not complete. The solution is to delete the crashing pods manually and recovery process will continue.
</p>
</li>
<li>
<p>
Long cluster names cause routes to be rejected (RED25871) - A cluster name longer than 20 characters will result in a rejected route configuration as the host part of the domain name exceeds 63 characters. The workaround is to limit cluster name to 20 characters or less.
</p>
</li>
<li>
<p>
No cleanup of database services on failures (RED25825) - The service broker doesn't clean up database service bindings when there are failures. The workaround is to manually remove service bindings.
</p>
</li>
<li>
<p>
Server broker errors with two service naming schemes (RED25547) - The service broker deployment results in an error when two types of service naming schemes are set. You must choose one of the methods if both are set - redis-port is the recommended default.
</p>
</li>
<li>
<p>
Cluster CR (REC) errors are not reported after invalid updates (RED25542) - A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</p>
</li>
<li>
<p>
An unreachable cluster has status running (RED32805) - When a cluster is in an unreachable state the state is still running instead of being reported as an error.
</p>
</li>
<li>
<p>
Readiness probe incorrect on failures (RED39300) - STS Readiness probe doesn't mark a node as not ready when rladmin status on the node fails
</p>
</li>
<li>
<p>
Role missing on replica sets (RED39002) - The redis-enterprise-operator role is missing permission on replica sets.
</p>
</li>
<li>
<p>
Private registries are not supported on OpenShift 3.11 (RED38579) - Openshift 3.11 doesn't support dockerhub private registry. This is a known OpenShift issue.
</p>
</li>
<li>
<p>
Internal DNS and K8s DNS may have conflicts (RED37462) - DNS conflicts are possible between the cluster mdns_server and the K8s DNS. This only impacts DNS resolution from within cluster nodes for K8s DNS names.
</p>
</li>
<li>
<p>
5.4.10 negatively impacts 5.4.6 (RED37233) - K8S-based 5.4.10 clusters seem to negatively affect existing 5.4.6
</p>
</li>
<li>
<p>
Node CPU usage is reported instead of pod CPU usage (RED36884) - In Kubernetes, the node CPU usage we report on is the usage of the K8S worker node hosting the REC pod.
</p>
</li>
<li>
<p>
Clusters must be named "rec" in OLM-based deployments (RED39825) - 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) is bound to a specific service account name (i.e., "rec"). The workaround is to name the cluster "rec".
</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/kubernetes/release-notes/previous-releases/k8s-6-0-6-11/"/>
<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/actions/bdb/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Database actions requests
</h1>
<p class="text-lg -mt-5 mb-10">
Database actions requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-db-actions">
GET
</a>
</td>
<td>
<code>
/v1/actions/bdb/{bdb_uid}
</code>
</td>
<td>
Get the status of a specific database's actions
</td>
</tr>
</tbody>
</table>
<h2 id="get-db-actions">
Get database actions
</h2>
<pre tabindex="0"><code>GET /v1/actions/bdb/{bdb_uid}
</code></pre>
<p>
Get the status of all currently executing, pending, or completed state-machine-related actions for a specific database. This API tracks short-lived API requests that return
<code>
action_uid
</code>
.
</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/#view_status_of_cluster_action">
view_status_of_cluster_action
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre tabindex="0"><code>GET /actions/bdb/1
</code></pre>
<h4 id="url-parameters">
URL parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
bdb_uid
</td>
<td>
string
</td>
<td>
Unique database ID
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns an array of JSON objects with attributes from
<a href="/docs/latest/operate/rs/references/rest-api/objects/action/">
actions
</a>
and
<a href="/docs/latest/operate/rs/references/rest-api/objects/state-machine/">
state machines
</a>
.
</p>
<p>
Each action contains the following attributes:
<code>
name
</code>
,
<code>
action_uid
</code>
,
<code>
status
</code>
, and
<code>
progress
</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">"action_uid"</span><span class="p">:</span> <span class="s2">"8afc7f70-f3ae-4244-a5e9-5133e78b2e97"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"heartbeat"</span><span class="p">:</span> <span class="mi">1703067908</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"SMUpdateBDB"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"object_name"</span><span class="p">:</span> <span class="s2">"bdb:1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_ops"</span><span class="p">:</span> <span class="p">{},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"progress"</span><span class="p">:</span> <span class="mf">50.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="s2">"proxy_policy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span> <span class="s2">"active"</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, response provides info about state-machine actions
</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>
</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/actions/bdb/"/>
<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/punsubscribe/.html | <section class="prose w-full py-12">
<h1 class="command-name">
PUNSUBSCRIBE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">PUNSUBSCRIBE [pattern [pattern ...]]</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 number of patterns to unsubscribe.
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@pubsub
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Unsubscribes the client from the given patterns, or from all of them if none is
given.
</p>
<p>
When no patterns are specified, the client is unsubscribed from all the
previously subscribed patterns.
In this case, a message for every unsubscribed pattern will be sent to the
client.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
When successful, this command doesn't return anything. Instead, for each pattern, one message with the first element being the string
<code>
punsubscribe
</code>
is pushed as a confirmation that the command succeeded.
<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/punsubscribe/"/>
<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/crdb/instance_info/.html | <section class="prose w-full py-12 max-w-none">
<h1>
CRDB instance info object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents Active-Active instance info
</p>
<p>
An object that represents Active-Active instance info.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
id
</td>
<td>
integer
</td>
<td>
Unique instance ID
</td>
</tr>
<tr>
<td>
cluster
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/cluster_info/">
CRDB cluster_info
</a>
object
</td>
<td>
</td>
</tr>
<tr>
<td>
compression
</td>
<td>
integer
</td>
<td>
Compression level when syncing from this source
</td>
</tr>
<tr>
<td>
db_config
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/database_config/">
CRDB database_config
</a>
object
</td>
<td>
Database configuration
</td>
</tr>
<tr>
<td>
db_uid
</td>
<td>
string
</td>
<td>
ID of local database instance. This field is likely to be empty for instances other than the local one.
</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/crdb/instance_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/use/patterns/twitter-clone/.html | <section class="prose w-full py-12">
<h1>
Redis patterns example
</h1>
<p class="text-lg -mt-5 mb-10">
Learn several Redis patterns by building a Twitter clone
</p>
<p>
This article describes the design and implementation of a
<a href="https://github.com/antirez/retwis">
very simple Twitter clone
</a>
written using PHP with Redis as the only database. The programming community has traditionally considered key-value stores as a special purpose database that couldn't be used as a drop-in replacement for a relational database for the development of web applications. This article will try to show that Redis data structures on top of a key-value layer are an effective data model to implement many kinds of applications.
</p>
<p>
Note: the original version of this article was written in 2009 when Redis was
released. It was not exactly clear at that time that the Redis data model was
suitable to write entire applications. Now after 5 years there are many cases of
applications using Redis as their main store, so the goal of the article today
is to be a tutorial for Redis newcomers. You'll learn how to design a simple
data layout using Redis, and how to apply different data structures.
</p>
<p>
Our Twitter clone, called
<a href="https://github.com/antirez/retwis">
Retwis
</a>
, is structurally simple, has very good performance, and can be distributed among any number of web and Redis servers with little efforts.
<a href="https://github.com/antirez/retwis">
View the Retwis source code
</a>
.
</p>
<p>
I used PHP for the example because of its universal readability. The same (or better) results can be obtained using Ruby, Python, Erlang, and so on.
A few clones exist (however not all the clones use the same data layout as the
current version of this tutorial, so please, stick with the official PHP
implementation for the sake of following the article better).
</p>
<ul>
<li>
<a href="https://github.com/danlucraft/retwis-rb">
Retwis-RB
</a>
is a port of Retwis to Ruby and Sinatra written by Daniel Lucraft.
</li>
<li>
<a href="https://docs.spring.io/spring-data/data-keyvalue/examples/retwisj/current/">
Retwis-J
</a>
is a port of Retwis to Java, using the Spring Data Framework, written by
<a href="http://twitter.com/costinl">
Costin Leau
</a>
. Its source code can be found on
<a href="https://github.com/SpringSource/spring-data-keyvalue-examples">
GitHub
</a>
, and there is comprehensive documentation available at
<a href="http://j.mp/eo6z6I">
springsource.org
</a>
.
</li>
</ul>
<h2 id="what-is-a-key-value-store">
What is a key-value store?
</h2>
<p>
The essence of a key-value store is the ability to store some data, called a
<em>
value
</em>
, inside a key. The value can be retrieved later only if we know the specific key it was stored in. There is no direct way to search for a key by value. In some sense, it is like a very large hash/dictionary, but it is persistent, i.e. when your application ends, the data doesn't go away. So, for example, I can use the command
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
to store the value
<em>
bar
</em>
in the key
<em>
foo
</em>
:
</p>
<pre><code>SET foo bar
</code></pre>
<p>
Redis stores data permanently, so if I later ask "
<em>
What is the value stored in key foo?
</em>
" Redis will reply with
<em>
bar
</em>
:
</p>
<pre><code>GET foo => bar
</code></pre>
<p>
Other common operations provided by key-value stores are
<a href="/docs/latest/commands/del/">
<code>
DEL
</code>
</a>
, to delete a given key and its associated value, SET-if-not-exists (called
<a href="/docs/latest/commands/setnx/">
<code>
SETNX
</code>
</a>
on Redis), to assign a value to a key only if the key does not already exist, and
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
, to atomically increment a number stored in a given key:
</p>
<pre><code>SET foo 10
INCR foo => 11
INCR foo => 12
INCR foo => 13
</code></pre>
<h2 id="atomic-operations">
Atomic operations
</h2>
<p>
There is something special about
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
. You may wonder why Redis provides such an operation if we can do it ourselves with a bit of code? After all, it is as simple as:
</p>
<pre><code>x = GET foo
x = x + 1
SET foo x
</code></pre>
<p>
The problem is that incrementing this way will work as long as there is only one client working with the key
<em>
foo
</em>
at one time. See what happens if two clients are accessing this key at the same time:
</p>
<pre><code>x = GET foo (yields 10)
y = GET foo (yields 10)
x = x + 1 (x is now 11)
y = y + 1 (y is now 11)
SET foo x (foo is now 11)
SET foo y (foo is now 11)
</code></pre>
<p>
Something is wrong! We incremented the value two times, but instead of going from 10 to 12, our key holds 11. This is because the increment done with
<code>
GET / increment / SET
</code>
<em>
is not an atomic operation
</em>
. Instead the INCR provided by Redis, Memcached, ..., are atomic implementations, and the server will take care of protecting the key during the time needed to complete the increment in order to prevent simultaneous accesses.
</p>
<p>
What makes Redis different from other key-value stores is that it provides other operations similar to INCR that can be used to model complex problems. This is why you can use Redis to write whole web applications without using another database like an SQL database, and without going crazy.
</p>
<h2 id="beyond-key-value-stores-lists">
Beyond key-value stores: lists
</h2>
<p>
In this section we will see which Redis features we need to build our Twitter clone. The first thing to know is that Redis values can be more than strings. Redis supports Lists, Sets, Hashes, Sorted Sets, Bitmaps, and HyperLogLog types as values, and there are atomic operations to operate on them so we are safe even with multiple accesses to the same key. Let's start with Lists:
</p>
<pre><code>LPUSH mylist a (now mylist holds 'a')
LPUSH mylist b (now mylist holds 'b','a')
LPUSH mylist c (now mylist holds 'c','b','a')
</code></pre>
<p>
<a href="/docs/latest/commands/lpush/">
<code>
LPUSH
</code>
</a>
means
<em>
Left Push
</em>
, that is, add an element to the left (or to the head) of the list stored in
<em>
mylist
</em>
. If the key
<em>
mylist
</em>
does not exist it is automatically created as an empty list before the PUSH operation. As you can imagine, there is also an
<a href="/docs/latest/commands/rpush/">
<code>
RPUSH
</code>
</a>
operation that adds the element to the right of the list (on the tail). This is very useful for our Twitter clone. User updates can be added to a list stored in
<code>
username:updates
</code>
, for instance.
</p>
<p>
There are operations to get data from Lists, of course. For instance, LRANGE returns a range from the list, or the whole list.
</p>
<pre><code>LRANGE mylist 0 1 => c,b
</code></pre>
<p>
LRANGE uses zero-based indexes - that is the first element is 0, the second 1, and so on. The command arguments are
<code>
LRANGE key first-index last-index
</code>
. The
<em>
last-index
</em>
argument can be negative, with a special meaning: -1 is the last element of the list, -2 the penultimate, and so on. So, to get the whole list use:
</p>
<pre><code>LRANGE mylist 0 -1 => c,b,a
</code></pre>
<p>
Other important operations are LLEN that returns the number of elements in the list, and LTRIM that is like LRANGE but instead of returning the specified range
<em>
trims
</em>
the list, so it is like
<em>
Get range from mylist, Set this range as new value
</em>
but does so atomically.
</p>
<h2 id="the-set-data-type">
The Set data type
</h2>
<p>
Currently we don't use the Set type in this tutorial, but since we use
Sorted Sets, which are kind of a more capable version of Sets, it is better
to start introducing Sets first (which are a very useful data structure
per se), and later Sorted Sets.
</p>
<p>
There are more data types than just Lists. Redis also supports Sets, which are unsorted collections of elements. It is possible to add, remove, and test for existence of members, and perform the intersection between different Sets. Of course it is possible to get the elements of a Set. Some examples will make it more clear. Keep in mind that
<a href="/docs/latest/commands/sadd/">
<code>
SADD
</code>
</a>
is the
<em>
add to set
</em>
operation,
<a href="/docs/latest/commands/srem/">
<code>
SREM
</code>
</a>
is the
<em>
remove from set
</em>
operation,
<a href="/docs/latest/commands/sismember/">
<code>
SISMEMBER
</code>
</a>
is the
<em>
test if member
</em>
operation, and
<a href="/docs/latest/commands/sinter/">
<code>
SINTER
</code>
</a>
is the
<em>
perform intersection
</em>
operation. Other operations are
<a href="/docs/latest/commands/scard/">
<code>
SCARD
</code>
</a>
to get the cardinality (the number of elements) of a Set, and
<a href="/docs/latest/commands/smembers/">
<code>
SMEMBERS
</code>
</a>
to return all the members of a Set.
</p>
<pre><code>SADD myset a
SADD myset b
SADD myset foo
SADD myset bar
SCARD myset => 4
SMEMBERS myset => bar,a,foo,b
</code></pre>
<p>
Note that
<a href="/docs/latest/commands/smembers/">
<code>
SMEMBERS
</code>
</a>
does not return the elements in the same order we added them since Sets are
<em>
unsorted
</em>
collections of elements. When you want to store in order it is better to use Lists instead. Some more operations against Sets:
</p>
<pre><code>SADD mynewset b
SADD mynewset foo
SADD mynewset hello
SINTER myset mynewset => foo,b
</code></pre>
<p>
<a href="/docs/latest/commands/sinter/">
<code>
SINTER
</code>
</a>
can return the intersection between Sets but it is not limited to two Sets. You may ask for the intersection of 4,5, or 10000 Sets. Finally let's check how
<a href="/docs/latest/commands/sismember/">
<code>
SISMEMBER
</code>
</a>
works:
</p>
<pre><code>SISMEMBER myset foo => 1
SISMEMBER myset notamember => 0
</code></pre>
<h2 id="the-sorted-set-data-type">
The Sorted Set data type
</h2>
<p>
Sorted Sets are similar to Sets: collection of elements. However in Sorted
Sets each element is associated with a floating point value, called the
<em>
element score
</em>
. Because of the score, elements inside a Sorted Set are
ordered, since we can always compare two elements by score (and if the score
happens to be the same, we compare the two elements as strings).
</p>
<p>
Like Sets in Sorted Sets it is not possible to add repeated elements, every
element is unique. However it is possible to update an element's score.
</p>
<p>
Sorted Set commands are prefixed with
<code>
Z
</code>
. The following is an example
of Sorted Sets usage:
</p>
<pre><code>ZADD zset 10 a
ZADD zset 5 b
ZADD zset 12.55 c
ZRANGE zset 0 -1 => b,a,c
</code></pre>
<p>
In the above example we added a few elements with
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
, and later retrieved
the elements with
<a href="/docs/latest/commands/zrange/">
<code>
ZRANGE
</code>
</a>
. As you can see the elements are returned in order
according to their score. In order to check if a given element exists, and
also to retrieve its score if it exists, we use the
<a href="/docs/latest/commands/zscore/">
<code>
ZSCORE
</code>
</a>
command:
</p>
<pre><code>ZSCORE zset a => 10
ZSCORE zset non_existing_element => NULL
</code></pre>
<p>
Sorted Sets are a very powerful data structure, you can query elements by
score range, lexicographically, in reverse order, and so forth.
To know more
<a href="/docs/latest/commands/#sorted_set">
please check the Sorted Set sections in the official Redis commands documentation
</a>
.
</p>
<h2 id="the-hash-data-type">
The Hash data type
</h2>
<p>
This is the last data structure we use in our program, and is extremely easy
to grasp since there is an equivalent in almost every programming language out
there: Hashes. Redis Hashes are basically like Ruby or Python hashes, a
collection of fields associated with values:
</p>
<pre><code>HMSET myuser name Salvatore surname Sanfilippo country Italy
HGET myuser surname => Sanfilippo
</code></pre>
<p>
<a href="/docs/latest/commands/hmset/">
<code>
HMSET
</code>
</a>
can be used to set fields in the hash, that can be retrieved with
<a href="/docs/latest/commands/hget/">
<code>
HGET
</code>
</a>
later. It is possible to check if a field exists with
<a href="/docs/latest/commands/hexists/">
<code>
HEXISTS
</code>
</a>
, or
to increment a hash field with
<a href="/docs/latest/commands/hincrby/">
<code>
HINCRBY
</code>
</a>
and so forth.
</p>
<p>
Hashes are the ideal data structure to represent
<em>
objects
</em>
. For example we
use Hashes in order to represent Users and Updates in our Twitter clone.
</p>
<p>
Okay, we just exposed the basics of the Redis main data structures,
we are ready to start coding!
</p>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
If you haven't downloaded the
<a href="https://github.com/antirez/retwis">
Retwis source code
</a>
already please grab it now. It contains a few PHP files, and also a copy of
<a href="https://github.com/nrk/predis">
Predis
</a>
, the PHP client library we use in this example.
</p>
<p>
Another thing you probably want is a working Redis server. Just get the source, build with
<code>
make
</code>
, run with
<code>
./redis-server
</code>
, and you're ready to go. No configuration is required at all in order to play with or run Retwis on your computer.
</p>
<h2 id="data-layout">
Data layout
</h2>
<p>
When working with a relational database, a database schema must be designed so that we'd know the tables, indexes, and so on that the database will contain. We don't have tables in Redis, so what do we need to design? We need to identify what keys are needed to represent our objects and what kind of values these keys need to hold.
</p>
<p>
Let's start with Users. We need to represent users, of course, with their username, userid, password, the set of users following a given user, the set of users a given user follows, and so on. The first question is, how should we identify a user? Like in a relational DB, a good solution is to identify different users with different numbers, so we can associate a unique ID with every user. Every other reference to this user will be done by id. Creating unique IDs is very simple to do by using our atomic
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
operation. When we create a new user we can do something like this, assuming the user is called "antirez":
</p>
<pre><code>INCR next_user_id => 1000
HMSET user:1000 username antirez password p1pp0
</code></pre>
<p>
<em>
Note: you should use a hashed password in a real application, for simplicity
we store the password in clear text.
</em>
</p>
<p>
We use the
<code>
next_user_id
</code>
key in order to always get a unique ID for every new user. Then we use this unique ID to name the key holding a Hash with user's data.
<em>
This is a common design pattern
</em>
with key-values stores! Keep it in mind.
Besides the fields already defined, we need some more stuff in order to fully define a User. For example, sometimes it can be useful to be able to get the user ID from the username, so every time we add a user, we also populate the
<code>
users
</code>
key, which is a Hash, with the username as field, and its ID as value.
</p>
<pre><code>HSET users antirez 1000
</code></pre>
<p>
This may appear strange at first, but remember that we are only able to access data in a direct way, without secondary indexes. It's not possible to tell Redis to return the key that holds a specific value. This is also
<em>
our strength
</em>
. This new paradigm is forcing us to organize data so that everything is accessible by
<em>
primary key
</em>
, speaking in relational DB terms.
</p>
<h2 id="followers-following-and-updates">
Followers, following, and updates
</h2>
<p>
There is another central need in our system. A user might have users who follow them, which we'll call their followers. A user might follow other users, which we'll call a following. We have a perfect data structure for this. That is... Sets.
The uniqueness of Sets elements, and the fact we can test in constant time for
existence, are two interesting features. However what about also remembering
the time at which a given user started following another one? In an enhanced
version of our simple Twitter clone this may be useful, so instead of using
a simple Set, we use a Sorted Set, using the user ID of the following or follower
user as element, and the unix time at which the relation between the users
was created, as our score.
</p>
<p>
So let's define our keys:
</p>
<pre><code>followers:1000 => Sorted Set of uids of all the followers users
following:1000 => Sorted Set of uids of all the following users
</code></pre>
<p>
We can add new followers with:
</p>
<pre><code>ZADD followers:1000 1401267618 1234 => Add user 1234 with time 1401267618
</code></pre>
<p>
Another important thing we need is a place where we can add the updates to display in the user's home page. We'll need to access this data in chronological order later, from the most recent update to the oldest, so the perfect kind of data structure for this is a List. Basically every new update will be
<a href="/docs/latest/commands/lpush/">
<code>
LPUSH
</code>
</a>
ed in the user updates key, and thanks to
<a href="/docs/latest/commands/lrange/">
<code>
LRANGE
</code>
</a>
, we can implement pagination and so on. Note that we use the words
<em>
updates
</em>
and
<em>
posts
</em>
interchangeably, since updates are actually "little posts" in some way.
</p>
<pre><code>posts:1000 => a List of post ids - every new post is LPUSHed here.
</code></pre>
<p>
This list is basically the User timeline. We'll push the IDs of her/his own
posts, and, the IDs of all the posts of created by the following users.
Basically, we'll implement a write fanout.
</p>
<h2 id="authentication">
Authentication
</h2>
<p>
OK, we have more or less everything about the user except for authentication. We'll handle authentication in a simple but robust way: we don't want to use PHP sessions, as our system must be ready to be distributed among different web servers easily, so we'll keep the whole state in our Redis database. All we need is a random
<strong>
unguessable
</strong>
string to set as the cookie of an authenticated user, and a key that will contain the user ID of the client holding the string.
</p>
<p>
We need two things in order to make this thing work in a robust way.
First: the current authentication
<em>
secret
</em>
(the random unguessable string)
should be part of the User object, so when the user is created we also set
an
<code>
auth
</code>
field in its Hash:
</p>
<pre><code>HSET user:1000 auth fea5e81ac8ca77622bed1c2132a021f9
</code></pre>
<p>
Moreover, we need a way to map authentication secrets to user IDs, so
we also take an
<code>
auths
</code>
key, which has as value a Hash type mapping
authentication secrets to user IDs.
</p>
<pre><code>HSET auths fea5e81ac8ca77622bed1c2132a021f9 1000
</code></pre>
<p>
In order to authenticate a user we'll do these simple steps (see the
<code>
login.php
</code>
file in the Retwis source code):
</p>
<ul>
<li>
Get the username and password via the login form.
</li>
<li>
Check if the
<code>
username
</code>
field actually exists in the
<code>
users
</code>
Hash.
</li>
<li>
If it exists we have the user id, (i.e. 1000).
</li>
<li>
Check if user:1000 password matches, if not, return an error message.
</li>
<li>
Ok authenticated! Set "fea5e81ac8ca77622bed1c2132a021f9" (the value of user:1000
<code>
auth
</code>
field) as the "auth" cookie.
</li>
</ul>
<p>
This is the actual code:
</p>
<pre><code>include("retwis.php");
# Form sanity checks
if (!gt("username") || !gt("password"))
goback("You need to enter both username and password to login.");
# The form is ok, check if the username is available
$username = gt("username");
$password = gt("password");
$r = redisLink();
$userid = $r->hget("users",$username);
if (!$userid)
goback("Wrong username or password");
$realpassword = $r->hget("user:$userid","password");
if ($realpassword != $password)
goback("Wrong username or password");
# Username / password OK, set the cookie and redirect to index.php
$authsecret = $r->hget("user:$userid","auth");
setcookie("auth",$authsecret,time()+3600*24*365);
header("Location: index.php");
</code></pre>
<p>
This happens every time a user logs in, but we also need a function
<code>
isLoggedIn
</code>
in order to check if a given user is already authenticated or not. These are the logical steps preformed by the
<code>
isLoggedIn
</code>
function:
</p>
<ul>
<li>
Get the "auth" cookie from the user. If there is no cookie, the user is not logged in, of course. Let's call the value of the cookie
<code>
<authcookie>
</code>
.
</li>
<li>
Check if
<code>
<authcookie>
</code>
field in the
<code>
auths
</code>
Hash exists, and what the value (the user ID) is (1000 in the example).
</li>
<li>
In order for the system to be more robust, also verify that user:1000 auth field also matches.
</li>
<li>
OK the user is authenticated, and we loaded a bit of information in the
<code>
$User
</code>
global variable.
</li>
</ul>
<p>
The code is simpler than the description, possibly:
</p>
<pre><code>function isLoggedIn() {
global $User, $_COOKIE;
if (isset($User)) return true;
if (isset($_COOKIE['auth'])) {
$r = redisLink();
$authcookie = $_COOKIE['auth'];
if ($userid = $r->hget("auths",$authcookie)) {
if ($r->hget("user:$userid","auth") != $authcookie) return false;
loadUserInfo($userid);
return true;
}
}
return false;
}
function loadUserInfo($userid) {
global $User;
$r = redisLink();
$User['id'] = $userid;
$User['username'] = $r->hget("user:$userid","username");
return true;
}
</code></pre>
<p>
Having
<code>
loadUserInfo
</code>
as a separate function is overkill for our application, but it's a good approach in a complex application. The only thing that's missing from all the authentication is the logout. What do we do on logout? That's simple, we'll just change the random string in user:1000
<code>
auth
</code>
field, remove the old authentication secret from the
<code>
auths
</code>
Hash, and add the new one.
</p>
<p>
<em>
Important:
</em>
the logout procedure explains why we don't just authenticate the user after looking up the authentication secret in the
<code>
auths
</code>
Hash, but double check it against user:1000
<code>
auth
</code>
field. The true authentication string is the latter, while the
<code>
auths
</code>
Hash is just an authentication field that may even be volatile, or, if there are bugs in the program or a script gets interrupted, we may even end with multiple entries in the
<code>
auths
</code>
key pointing to the same user ID. The logout code is the following (
<code>
logout.php
</code>
):
</p>
<pre><code>include("retwis.php");
if (!isLoggedIn()) {
header("Location: index.php");
exit;
}
$r = redisLink();
$newauthsecret = getrand();
$userid = $User['id'];
$oldauthsecret = $r->hget("user:$userid","auth");
$r->hset("user:$userid","auth",$newauthsecret);
$r->hset("auths",$newauthsecret,$userid);
$r->hdel("auths",$oldauthsecret);
header("Location: index.php");
</code></pre>
<p>
That is just what we described and should be simple to understand.
</p>
<h2 id="updates">
Updates
</h2>
<p>
Updates, also known as posts, are even simpler. In order to create a new post in the database we do something like this:
</p>
<pre><code>INCR next_post_id => 10343
HMSET post:10343 user_id $owner_id time $time body "I'm having fun with Retwis"
</code></pre>
<p>
As you can see each post is just represented by a Hash with three fields. The ID of the user owning the post, the time at which the post was published, and finally, the body of the post, which is, the actual status message.
</p>
<p>
After we create a post and we obtain the post ID, we need to LPUSH the ID in the timeline of every user that is following the author of the post, and of course in the list of posts of the author itself (everybody is virtually following herself/himself). This is the file
<code>
post.php
</code>
that shows how this is performed:
</p>
<pre><code>include("retwis.php");
if (!isLoggedIn() || !gt("status")) {
header("Location:index.php");
exit;
}
$r = redisLink();
$postid = $r->incr("next_post_id");
$status = str_replace("\n"," ",gt("status"));
$r->hmset("post:$postid","user_id",$User['id'],"time",time(),"body",$status);
$followers = $r->zrange("followers:".$User['id'],0,-1);
$followers[] = $User['id']; /* Add the post to our own posts too */
foreach($followers as $fid) {
$r->lpush("posts:$fid",$postid);
}
# Push the post on the timeline, and trim the timeline to the
# newest 1000 elements.
$r->lpush("timeline",$postid);
$r->ltrim("timeline",0,1000);
header("Location: index.php");
</code></pre>
<p>
The core of the function is the
<code>
foreach
</code>
loop. We use
<a href="/docs/latest/commands/zrange/">
<code>
ZRANGE
</code>
</a>
to get all the followers of the current user, then the loop will
<a href="/docs/latest/commands/lpush/">
<code>
LPUSH
</code>
</a>
the push the post in every follower timeline List.
</p>
<p>
Note that we also maintain a global timeline for all the posts, so that in the Retwis home page we can show everybody's updates easily. This requires just doing an
<a href="/docs/latest/commands/lpush/">
<code>
LPUSH
</code>
</a>
to the
<code>
timeline
</code>
List. Let's face it, aren't you starting to think it was a bit strange to have to sort things added in chronological order using
<code>
ORDER BY
</code>
with SQL? I think so.
</p>
<p>
There is an interesting thing to notice in the code above: we used a new
command called
<a href="/docs/latest/commands/ltrim/">
<code>
LTRIM
</code>
</a>
after we perform the
<a href="/docs/latest/commands/lpush/">
<code>
LPUSH
</code>
</a>
operation in the global
timeline. This is used in order to trim the list to just 1000 elements. The
global timeline is actually only used in order to show a few posts in the
home page, there is no need to have the full history of all the posts.
</p>
<p>
Basically
<a href="/docs/latest/commands/ltrim/">
<code>
LTRIM
</code>
</a>
+
<a href="/docs/latest/commands/lpush/">
<code>
LPUSH
</code>
</a>
is a way to create a
<em>
capped collection
</em>
in Redis.
</p>
<h2 id="paginating-updates">
Paginating updates
</h2>
<p>
Now it should be pretty clear how we can use
<a href="/docs/latest/commands/lrange/">
<code>
LRANGE
</code>
</a>
in order to get ranges of posts, and render these posts on the screen. The code is simple:
</p>
<pre><code>function showPost($id) {
$r = redisLink();
$post = $r->hgetall("post:$id");
if (empty($post)) return false;
$userid = $post['user_id'];
$username = $r->hget("user:$userid","username");
$elapsed = strElapsed($post['time']);
$userlink = "<a class=\"username\" href=\"profile.php?u=".urlencode($username)."\">".utf8entities($username)."</a>";
echo('<div class="post">'.$userlink.' '.utf8entities($post['body'])."<br>");
echo('<i>posted '.$elapsed.' ago via web</i></div>');
return true;
}
function showUserPosts($userid,$start,$count) {
$r = redisLink();
$key = ($userid == -1) ? "timeline" : "posts:$userid";
$posts = $r->lrange($key,$start,$start+$count);
$c = 0;
foreach($posts as $p) {
if (showPost($p)) $c++;
if ($c == $count) break;
}
return count($posts) == $count+1;
}
</code></pre>
<p>
<code>
showPost
</code>
will simply convert and print a Post in HTML while
<code>
showUserPosts
</code>
gets a range of posts and then passes them to
<code>
showPosts
</code>
.
</p>
<p>
<em>
Note:
<a href="/docs/latest/commands/lrange/">
<code>
LRANGE
</code>
</a>
is not very efficient if the list of posts start to be very
big, and we want to access elements which are in the middle of the list, since Redis Lists are backed by linked lists. If a system is designed for
deep pagination of million of items, it is better to resort to Sorted Sets
instead.
</em>
</p>
<h2 id="following-users">
Following users
</h2>
<p>
It is not hard, but we did not yet check how we create following / follower relationships. If user ID 1000 (antirez) wants to follow user ID 5000 (pippo), we need to create both a following and a follower relationship. We just need to
<a href="/docs/latest/commands/zadd/">
<code>
ZADD
</code>
</a>
calls:
</p>
<pre><code> ZADD following:1000 5000
ZADD followers:5000 1000
</code></pre>
<p>
Note the same pattern again and again. In theory with a relational database, the list of following and followers would be contained in a single table with fields like
<code>
following_id
</code>
and
<code>
follower_id
</code>
. You can extract the followers or following of every user using an SQL query. With a key-value DB things are a bit different since we need to set both the
<code>
1000 is following 5000
</code>
and
<code>
5000 is followed by 1000
</code>
relations. This is the price to pay, but on the other hand accessing the data is simpler and extremely fast. Having these things as separate sets allows us to do interesting stuff. For example, using
<a href="/docs/latest/commands/zinterstore/">
<code>
ZINTERSTORE
</code>
</a>
we can have the intersection of
<code>
following
</code>
of two different users, so we may add a feature to our Twitter clone so that it is able to tell you very quickly when you visit somebody else's profile, "you and Alice have 34 followers in common", and things like that.
</p>
<p>
You can find the code that sets or removes a following / follower relation in the
<code>
follow.php
</code>
file.
</p>
<h2 id="making-it-horizontally-scalable">
Making it horizontally scalable
</h2>
<p>
Gentle reader, if you read till this point you are already a hero. Thank you. Before talking about scaling horizontally it is worth checking performance on a single server. Retwis is
<em>
extremely fast
</em>
, without any kind of cache. On a very slow and loaded server, an Apache benchmark with 100 parallel clients issuing 100000 requests measured the average pageview to take 5 milliseconds. This means you can serve millions of users every day with just a single Linux box, and this one was monkey ass slow... Imagine the results with more recent hardware.
</p>
<p>
However you can't go with a single server forever, how do you scale a key-value
store?
</p>
<p>
Retwis does not perform any multi-keys operation, so making it scalable is
simple: you may use client-side sharding, or something like a sharding proxy
like Twemproxy, or the upcoming Redis Cluster.
</p>
<p>
To know more about those topics please read
<a href="/docs/latest/operate/oss_and_stack/management/scaling/">
our documentation about sharding
</a>
. However, the point here
to stress is that in a key-value store, if you design with care, the data set
is split among
<strong>
many independent small keys
</strong>
. To distribute those keys
to multiple nodes is more straightforward and predictable compared to using
a semantically more complex database system.
</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/use/patterns/twitter-clone/"/>
<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/monitoring/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Monitoring with metrics and alerts
</h1>
<p class="text-lg -mt-5 mb-10">
Use the metrics that measure the performance of your Redis Enterprise Software clusters, nodes, databases, and shards to track the performance of your databases.
</p>
<p>
You can use the metrics that measure the performance of your Redis Enterprise Software clusters, nodes, databases, and shards
to monitor the performance of your databases.
In the Redis Enterprise Cluster Manager UI, you can view metrics, configure alerts, and send notifications based on alert parameters. You can also access metrics and configure alerts through the REST API.
</p>
<p>
Redis Enterprise version 7.8.2 introduces a preview of the new metrics stream engine that exposes the v2 Prometheus scraping endpoint at
<code>
https://<IP>:8070/v2
</code>
.
This new engine exports all time-series metrics to external monitoring tools such as Grafana, DataDog, NewRelic, and Dynatrace using Prometheus.
</p>
<p>
The new engine enables real-time monitoring, including full monitoring during maintenance operations, providing full visibility into performance during events such as shards' failovers and scaling operations.
</p>
<p>
If you are already using the existing scraping endpoint for integration, follow
<a href="/docs/latest/integrate/prometheus-with-redis-enterprise/prometheus-metrics-v1-to-v2/">
this guide
</a>
to transition and try the new engine. It is possible to scrape both existing and new endpoints simultaneously, allowing advanced dashboard preparation and a smooth transition.
</p>
<p>
To integrate Redis Enterprise metrics into your monitoring environment, see the integration guides for
<a href="/docs/latest/integrate/prometheus-with-redis-enterprise/">
Prometheus and Grafana
</a>
or
<a href="/docs/latest/integrate/uptrace-with-redis-enterprise/">
Uptrace
</a>
.
</p>
<p>
Make sure you read the
<a href="/docs/latest/operate/rs/references/metrics/">
definition of each metric
</a>
so that you understand exactly what it represents.
</p>
<h2 id="cluster-manager-metrics">
Cluster manager metrics
</h2>
<p>
You can see the metrics of the cluster in:
</p>
<ul>
<li>
<strong>
Cluster > Metrics
</strong>
</li>
<li>
<strong>
Node > Metrics
</strong>
for each node
</li>
<li>
<strong>
Database > Metrics
</strong>
for each database, including the shards for that database
</li>
</ul>
<p>
The scale selector at the top of the page allows you to set the X-axis (time) scale of the graph.
</p>
<p>
To choose which metrics to display in the two large graphs at the top of the page:
</p>
<ol>
<li>
Hover over the graph you want to show in a large graph.
</li>
<li>
Click on the right or left arrow to choose which side to show the graph.
</li>
</ol>
<p>
We recommend that you show two similar metrics in the top graphs so you can compare them side-by-side.
</p>
<h2 id="cluster-alerts">
Cluster alerts
</h2>
<p>
In
<strong>
Cluster > Alert Settings
</strong>
, you can enable alerts for node or cluster events, such as high memory usage or throughput.
</p>
<p>
Configured alerts are shown:
</p>
<ul>
<li>
As a notification on the status icon (
<a href="/docs/latest/images/rs/icons/icon_warning.png#no-click" sdata-lightbox="/images/rs/icons/icon_warning.png#no-click">
<img alt="Warning" class="inline" src="/docs/latest/images/rs/icons/icon_warning.png#no-click" width="18px"/>
</a>
) for the node and cluster
</li>
<li>
In the
<strong>
log
</strong>
</li>
<li>
In email notifications, if you configure
<a href="#send-alerts-by-email">
email alerts
</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>
If you enable alerts for "Node joined" or "Node removed" actions,
you must also enable "Receive email alerts" so that the notifications are sent.
</div>
</div>
<p>
To enable alerts for a cluster:
</p>
<ol>
<li>
In
<strong>
Cluster > Alert Settings
</strong>
, click
<strong>
Edit
</strong>
.
</li>
<li>
Select the alerts that you want to show for the cluster and click
<strong>
Save
</strong>
.
</li>
</ol>
<h2 id="database-alerts">
Database alerts
</h2>
<p>
For each database, you can enable alerts for database events, such as high memory usage or throughput.
</p>
<p>
Configured alerts are shown:
</p>
<ul>
<li>
As a notification on the status icon (
<a href="/docs/latest/images/rs/icons/icon_warning.png#no-click" sdata-lightbox="/images/rs/icons/icon_warning.png#no-click">
<img alt="Warning" class="inline" src="/docs/latest/images/rs/icons/icon_warning.png#no-click" width="18px"/>
</a>
) for the database
</li>
<li>
In the
<strong>
log
</strong>
</li>
<li>
In emails, if you configure
<a href="#send-alerts-by-email">
email alerts
</a>
</li>
</ul>
<p>
To enable alerts for a database:
</p>
<ol>
<li>
In
<strong>
Configuration
</strong>
for the database, click
<strong>
Edit
</strong>
.
</li>
<li>
Select the
<strong>
Alerts
</strong>
section to open it.
</li>
<li>
Select the alerts that you want to show for the database and click
<strong>
Save
</strong>
.
</li>
</ol>
<h2 id="send-alerts-by-email">
Send alerts by email
</h2>
<p>
To send cluster and database alerts by email:
</p>
<ol>
<li>
In
<strong>
Cluster > Alert Settings
</strong>
, click
<strong>
Edit
</strong>
.
</li>
<li>
Select
<strong>
Set an email
</strong>
to configure the
<a href="/docs/latest/operate/rs/clusters/configure/cluster-settings/#configuring-email-server-settings">
email server settings
</a>
.
</li>
<li>
In
<strong>
Configuration
</strong>
for the database, click
<strong>
Edit
</strong>
.
</li>
<li>
Select the
<strong>
Alerts
</strong>
section to open it.
</li>
<li>
Select
<strong>
Receive email alerts
</strong>
and click
<strong>
Save
</strong>
.
</li>
<li>
In
<strong>
Access Control
</strong>
, select the
<a href="/docs/latest/operate/rs/security/access-control/manage-users/">
database and cluster alerts
</a>
that you want each user to receive.
</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/monitoring/"/>
<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/policy/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Cluster policy requests
</h1>
<p class="text-lg -mt-5 mb-10">
Cluster policy requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-cluster-policy">
GET
</a>
</td>
<td>
<code>
/v1/cluster/policy
</code>
</td>
<td>
Get cluster policy settings
</td>
</tr>
<tr>
<td>
<a href="#put-cluster-policy">
PUT
</a>
</td>
<td>
<code>
/v1/cluster/policy
</code>
</td>
<td>
Update cluster policy settings
</td>
</tr>
</tbody>
</table>
<h2 id="get-cluster-policy">
Get cluster policy
</h2>
<pre><code>GET /v1/cluster/policy
</code></pre>
<p>
Gets the cluster's current policy settings.
</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/policy
</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_settings/">
cluster settings 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">"db_conns_auditing"</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">"default_non_sharded_proxy_policy"</span><span class="p">:</span> <span class="s2">"single"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"default_provisioned_redis_version"</span><span class="p">:</span> <span class="s2">"6.0"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"default_sharded_proxy_policy"</span><span class="p">:</span> <span class="s2">"single"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"default_shards_placement"</span><span class="p">:</span> <span class="s2">"dense"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"redis_upgrade_policy"</span><span class="p">:</span> <span class="s2">"major"</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="get-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">
200 OK
</a>
</td>
<td>
Success
</td>
</tr>
</tbody>
</table>
<h2 id="put-cluster-policy">
Update cluster policy
</h2>
<pre><code>PUT /v1/cluster/policy
</code></pre>
<p>
Update cluster policy settings.
</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/policy
</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">"default_shards_placement"</span><span class="p">:</span> <span class="s2">"sparse"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"default_sharded_proxy_policy"</span><span class="p">:</span> <span class="s2">"all-nodes"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<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="request-body">
Request body
</h4>
<p>
Include a
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/cluster_settings/">
cluster settings object
</a>
with updated fields in the request body.
</p>
<h3 id="put-response">
Response
</h3>
<p>
Returns a status code that indicates the success or failure of the cluster settings update.
</p>
<h3 id="put-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">
200 OK
</a>
</td>
<td>
Success
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request">
400 Bad Request
</a>
</td>
<td>
Failed to set parameters
</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/policy/"/>
<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/api/examples/audit-system-logs/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Audit using Service Log
</h1>
<p class="text-lg -mt-5 mb-10">
Use the service log to track and audit actions performed in the account
</p>
<p>
Service logs collect and report actions performed on various entities in your Redis Cloud subscription. These entities include the account itself, users, API Keys, subscriptions, databases, accounts, payment methods, and more. For each entity, various lifecycle events are logged in the system log.
</p>
<p>
To view the log, sign in to the
<a href="https://cloud.redis.io/">
Redis Cloud console
</a>
and then select
<strong>
Logs
</strong>
from the main menu.
</p>
<a href="/docs/latest/images/rc/system-logs.png" sdata-lightbox="/images/rc/system-logs.png">
<img alt="Choose the Logs command from the Redis Cloud console menu to view your subscription system log." src="/docs/latest/images/rc/system-logs.png" width="75%"/>
</a>
<p>
To learn more, see
<a href="/docs/latest/operate/rc/logs-reports/system-logs/">
System logs
</a>
.
</p>
<h3 id="system-log-rest-api">
System log REST API
</h3>
<p>
The REST API operation for querying the system service log is
<code>
GET /logs
</code>
.
</p>
<p>
For example, the following request returns the latest 100 system log entries, in descending order:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">GET <span class="s2">"https://[host]/v1/logs?limit=100&offset=0"</span>
</span></span></code></pre>
</div>
<p>
The
<code>
/logs
</code>
API operation accepts the following parameters:
</p>
<ul>
<li>
<code>
offset
</code>
- The starting point for the results. The default value of
<code>
0
</code>
starts with the latest log entry. A value of
<code>
11
</code>
skips the first 10 entries and retrieves entries starting with the 11 and older.
</li>
<li>
<code>
limit
</code>
- The maximum number of entries to return per request. The default value is
<code>
100
</code>
.
</li>
</ul>
<p>
The system log reports activity for the entire account. It reports log entries for all types of entities, including subscriptions, databases, and so on.
</p>
<h3 id="request-results">
Request results
</h3>
<p>
An API system log request results in data that includes an
<code>
entries
</code>
array. The entries are sorted by system log entry ID in descending order and include the following properties:
</p>
<ul>
<li>
<p>
<code>
id
</code>
- A unique identifier for each system log entry.
</p>
</li>
<li>
<p>
<code>
time
</code>
- The system log entry timestamp, defined in ISO-8601 date format and in the UTC timezone (for example:
<code>
2019-03-15T14:26:02Z
</code>
).
</p>
</li>
<li>
<p>
<code>
originator
</code>
- The name of the user who performed the action described by the system log entry.
</p>
</li>
<li>
<p>
<code>
apiKeyName
</code>
- The name of the API key used to perform the action described by the system log entry.
This field only appears if the action was performed through the API.
If the operation was performed through the Redis Cloud console, this property is omitted.
</p>
</li>
<li>
<p>
<code>
resource
</code>
- The name of the entity associated with the logged action (for example, database name).
This property is omitted if it is not applicable to the specific log entry.
</p>
</li>
<li>
<p>
<code>
type
</code>
- The category associated with the action log entry.
</p>
</li>
<li>
<p>
<code>
description
</code>
- The detailed description of the action in the log entry.
</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/api/examples/audit-system-logs/"/>
<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/incrbyfloat/.html | <section class="prose w-full py-12">
<h1 class="command-name">
INCRBYFLOAT
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">INCRBYFLOAT key increment</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.6.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>
@string
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Increment the string representing a floating point number stored at
<code>
key
</code>
by the
specified
<code>
increment
</code>
. By using a negative
<code>
increment
</code>
value, the result is
that the value stored at the key is decremented (by the obvious properties
of addition).
If the key does not exist, it is set to
<code>
0
</code>
before performing the operation.
An error is returned if one of the following conditions occur:
</p>
<ul>
<li>
The key contains a value of the wrong type (not a string).
</li>
<li>
The current key content or the specified increment are not parsable as a
double precision floating point number.
</li>
</ul>
<p>
If the command is successful the new incremented value is stored as the new
value of the key (replacing the old one), and returned to the caller as a
string.
</p>
<p>
Both the value already contained in the string key and the increment argument
can be optionally provided in exponential notation, however the value computed
after the increment is stored consistently in the same format, that is, an
integer number followed (if needed) by a dot, and a variable number of digits
representing the decimal part of the number.
Trailing zeroes are always removed.
</p>
<p>
The precision of the output is fixed at 17 digits after the decimal point
regardless of the actual internal precision of the computation.
</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> SET mykey 10.50
"OK"
redis> INCRBYFLOAT mykey 0.1
"10.6"
redis> INCRBYFLOAT mykey -5
"5.6"
redis> SET mykey 5.0e3
"OK"
redis> INCRBYFLOAT mykey 2.0e2
"5200"
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="implementation-details">
Implementation details
</h2>
<p>
The command is always propagated in the replication link and the Append Only
File as a
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
operation, so that differences in the underlying floating point
math implementation will not be sources of inconsistency.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the value of the key after the increment.
<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/incrbyfloat/"/>
<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>
|