doc/SidekiqUniqueJobs/Redis/SortedSet.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: SidekiqUniqueJobs::Redis::SortedSet
— Documentation by YARD 0.9.26
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "SidekiqUniqueJobs::Redis::SortedSet";
relpath = '../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (S)</a> »
<span class='title'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span> » <span class='title'><span class='object_link'><a href="../Redis.html" title="SidekiqUniqueJobs::Redis (module)">Redis</a></span></span>
»
<span class="title">SortedSet</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: SidekiqUniqueJobs::Redis::SortedSet
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName"><span class='object_link'><a href="Entity.html" title="SidekiqUniqueJobs::Redis::Entity (class)">Entity</a></span></span>
<ul class="fullTree">
<li>Object</li>
<li class="next"><span class='object_link'><a href="Entity.html" title="SidekiqUniqueJobs::Redis::Entity (class)">Entity</a></span></li>
<li class="next">SidekiqUniqueJobs::Redis::SortedSet</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/sidekiq_unique_jobs/redis/sorted_set.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Class SortedSet provides convenient access to redis sorted sets</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Author:</p>
<ul class="author">
<li>
<div class='inline'><p>Mikael Henriksson <a href="mailto:mikael@mhenrixon.com">mikael@mhenrixon.com</a></p>
</div>
</li>
</ul>
</div><div id="subclasses">
<h2>Direct Known Subclasses</h2>
<p class="children"><span class='object_link'><a href="../Changelog.html" title="SidekiqUniqueJobs::Changelog (class)">Changelog</a></span>, <span class='object_link'><a href="../Digests.html" title="SidekiqUniqueJobs::Digests (class)">Digests</a></span></p>
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(values) ⇒ Boolean, Integer </a>
</span>
<span class="summary_desc"><div class='inline'><p>Adds a value to the sorted set.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#clear-instance_method" title="#clear (instance method)">#<strong>clear</strong> ⇒ Integer </a>
</span>
<span class="summary_desc"><div class='inline'><p>Clears the sorted set from all entries.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#count-instance_method" title="#count (instance method)">#<strong>count</strong> ⇒ Integer </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the count for this sorted set.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#entries-instance_method" title="#entries (instance method)">#<strong>entries</strong>(with_scores: true) ⇒ Array<Object>, Hash </a>
</span>
<span class="summary_desc"><div class='inline'><p>Return entries for this sorted set.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#rank-instance_method" title="#rank (instance method)">#<strong>rank</strong>(member) ⇒ Integer </a>
</span>
<span class="summary_desc"><div class='inline'><p>Return the zrak of the member.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#score-instance_method" title="#score (instance method)">#<strong>score</strong>(member) ⇒ Integer, Float </a>
</span>
<span class="summary_desc"><div class='inline'><p>Return score for a member.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="Entity.html#initialize-instance_method" title="SidekiqUniqueJobs::Redis::Entity#initialize (method)">SidekiqUniqueJobs::Redis::Entity</a></span></p>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="add-instance_method">
#<strong>add</strong>(values) ⇒ <tt>Boolean</tt>, <tt>Integer</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Adds a value to the sorted set</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>values</span>
<span class='type'>(<tt><span class='object_link'><a href="../../Array.html" title="Array (class)">Array</a></span><Float, <span class='object_link'><a href="String.html" title="SidekiqUniqueJobs::Redis::String (class)">String</a></span>></tt>, <tt><span class='object_link'><a href="String.html" title="SidekiqUniqueJobs::Redis::String (class)">String</a></span></tt>)</span>
—
<div class='inline'><p>the values to add</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>, <tt>Integer</tt>)</span>
—
<div class='inline'><p><description></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
33
34
35
36
37
38
39
40
41</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 33</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
<span class='id identifier rubyid_redis'>redis</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../Array.html" title="Array (class)">Array</a></span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zadd'>zadd</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zadd'>zadd</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_now_f'>now_f</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="clear-instance_method">
#<strong>clear</strong> ⇒ <tt>Integer</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Clears the sorted set from all entries</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
—
<div class='inline'><p>number of entries removed</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
71
72
73</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 71</span>
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
<span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zremrangebyrank'>zremrangebyrank</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_count'>count</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="count-instance_method">
#<strong>count</strong> ⇒ <tt>Integer</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the count for this sorted set</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
—
<div class='inline'><p>the number of entries</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
81
82
83</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 81</span>
<span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span>
<span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zcard'>zcard</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="entries-instance_method">
#<strong>entries</strong>(with_scores: true) ⇒ <tt><span class='object_link'><a href="../../Array.html" title="Array (class)">Array</a></span><Object></tt>, <tt><span class='object_link'><a href="Hash.html" title="SidekiqUniqueJobs::Redis::Hash (class)">Hash</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Return entries for this sorted set</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>with_scores</span>
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
<em class="default">(defaults to: <tt>true</tt>)</em>
—
<div class='inline'><p>true return</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="../../Array.html" title="Array (class)">Array</a></span><Object></tt>)</span>
—
<div class='inline'><p>when given with_scores: false</p>
</div>
</li>
<li>
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="SidekiqUniqueJobs::Redis::Hash (class)">Hash</a></span></tt>)</span>
—
<div class='inline'><p>when given with_scores: true</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
19
20
21
22
23
24</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 19</span>
<span class='kw'>def</span> <span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='label'>with_scores:</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_entrys'>entrys</span> <span class='op'>=</span> <span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zrange'>zrange</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='label'>with_scores:</span> <span class='id identifier rubyid_with_scores'>with_scores</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>return</span> <span class='id identifier rubyid_entrys'>entrys</span> <span class='kw'>unless</span> <span class='id identifier rubyid_with_scores'>with_scores</span>
<span class='id identifier rubyid_entrys'>entrys</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_pair'>pair</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span> <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_pair'>pair</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_pair'>pair</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="rank-instance_method">
#<strong>rank</strong>(member) ⇒ <tt>Integer</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Return the zrak of the member</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>member</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="SidekiqUniqueJobs::Redis::String (class)">String</a></span></tt>)</span>
—
<div class='inline'><p>the member to pull rank on</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
50
51
52</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 50</span>
<span class='kw'>def</span> <span class='id identifier rubyid_rank'>rank</span><span class='lparen'>(</span><span class='id identifier rubyid_member'>member</span><span class='rparen'>)</span>
<span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zrank'>zrank</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_member'>member</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="score-instance_method">
#<strong>score</strong>(member) ⇒ <tt>Integer</tt>, <tt>Float</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Return score for a member</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>member</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="SidekiqUniqueJobs::Redis::String (class)">String</a></span></tt>)</span>
—
<div class='inline'><p>the member for which score</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>, <tt>Float</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
61
62
63</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 61</span>
<span class='kw'>def</span> <span class='id identifier rubyid_score'>score</span><span class='lparen'>(</span><span class='id identifier rubyid_member'>member</span><span class='rparen'>)</span>
<span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zscore'>zscore</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_member'>member</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Sep 27 15:29:08 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.2).
</div>
</div>
</body>
</html>