Module: Oxblood::Commands::Sets
- Included in:
- Oxblood::Commands
- Defined in:
- lib/oxblood/commands/sets.rb
Instance Method Summary collapse
-
#sadd(key, *members) ⇒ Integer
Add one or more members to a set.
-
#scard(key) ⇒ Integer
Get the number of members in a set.
-
#sdiff(*keys) ⇒ Array
Subtract multiple sets.
-
#sdiffstore(destination, *keys) ⇒ Integer
Subtract multiple sets and store the resulting set in a key.
-
#sinter(*keys) ⇒ Array
Intersect multiple sets.
-
#sinterstore(destination, *keys) ⇒ Integer
Intersect multiple sets and store the resulting key in a key.
-
#sismember(key, member) ⇒ Integer
Determine if a given value is a member of a set.
-
#smembers(key) ⇒ Array
Get all the members in a set.
-
#smove(source, destination, member) ⇒ Integer
Move a member from one set to another.
-
#spop(key, count = nil) ⇒ String, Array
Remove and return one or multiple random members from a set.
-
#srandmember(key, count = nil) ⇒ String, ...
Get one or multiple random members from a set.
-
#srem(key, *members) ⇒ Integer
Remove one or more members from a set.
-
#sscan(key, cursor, opts = {}) ⇒ Array
Incrementally iterate Set elements.
-
#sunion(*keys) ⇒ Array
Add multiple sets.
-
#sunionstore(destination, *keys) ⇒ Integer
Add multipe sets and store the resulting set in a key.
Instance Method Details
#sadd(key, *members) ⇒ Integer
Add one or more members to a set
14 15 16 |
# File 'lib/oxblood/commands/sets.rb', line 14 def sadd(key, *members) run(*members.unshift(:SADD, key)) end |
#scard(key) ⇒ Integer
Get the number of members in a set
25 26 27 |
# File 'lib/oxblood/commands/sets.rb', line 25 def scard(key) run(:SCARD, key) end |
#sdiff(*keys) ⇒ Array
Subtract multiple sets
35 36 37 |
# File 'lib/oxblood/commands/sets.rb', line 35 def sdiff(*keys) run(*keys.unshift(:SDIFF)) end |
#sdiffstore(destination, *keys) ⇒ Integer
Subtract multiple sets and store the resulting set in a key
46 47 48 |
# File 'lib/oxblood/commands/sets.rb', line 46 def sdiffstore(destination, *keys) run(*keys.unshift(:SDIFFSTORE, destination)) end |
#sinter(*keys) ⇒ Array
Intersect multiple sets
56 57 58 |
# File 'lib/oxblood/commands/sets.rb', line 56 def sinter(*keys) run(*keys.unshift(:SINTER)) end |
#sinterstore(destination, *keys) ⇒ Integer
Intersect multiple sets and store the resulting key in a key
67 68 69 |
# File 'lib/oxblood/commands/sets.rb', line 67 def sinterstore(destination, *keys) run(*keys.unshift(:SINTERSTORE, destination)) end |
#sismember(key, member) ⇒ Integer
Determine if a given value is a member of a set
79 80 81 |
# File 'lib/oxblood/commands/sets.rb', line 79 def sismember(key, member) run(:SISMEMBER, key, member) end |
#smembers(key) ⇒ Array
Get all the members in a set
89 90 91 |
# File 'lib/oxblood/commands/sets.rb', line 89 def smembers(key) run(:SMEMBERS, key) end |
#smove(source, destination, member) ⇒ Integer
Move a member from one set to another
102 103 104 |
# File 'lib/oxblood/commands/sets.rb', line 102 def smove(source, destination, member) run(:SMOVE, source, destination, member) end |
#spop(key, count = nil) ⇒ String, Array
Remove and return one or multiple random members from a set
117 118 119 120 121 |
# File 'lib/oxblood/commands/sets.rb', line 117 def spop(key, count = nil) args = [:SPOP, key] args << count if count run(*args) end |
#srandmember(key, count = nil) ⇒ String, ...
Get one or multiple random members from a set
134 135 136 137 138 |
# File 'lib/oxblood/commands/sets.rb', line 134 def srandmember(key, count = nil) args = [:SRANDMEMBER, key] args << count if count run(*args) end |
#srem(key, *members) ⇒ Integer
Remove one or more members from a set
148 149 150 |
# File 'lib/oxblood/commands/sets.rb', line 148 def srem(key, *members) run(*members.unshift(:SREM, key)) end |
#sscan(key, cursor, opts = {}) ⇒ Array
Incrementally iterate Set elements
186 187 188 189 190 |
# File 'lib/oxblood/commands/sets.rb', line 186 def sscan(key, cursor, opts = {}) args = [:SSCAN, key, cursor] Scan.merge_opts!(args, opts) run(*args) end |
#sunion(*keys) ⇒ Array
Add multiple sets
158 159 160 |
# File 'lib/oxblood/commands/sets.rb', line 158 def sunion(*keys) run(*keys.unshift(:SUNION)) end |
#sunionstore(destination, *keys) ⇒ Integer
Add multipe sets and store the resulting set in a key
169 170 171 |
# File 'lib/oxblood/commands/sets.rb', line 169 def sunionstore(destination, *keys) run(*keys.unshift(:SUNIONSTORE, destination)) end |