Module: Protocol::Redis::Methods::Sets
- Defined in:
- lib/protocol/redis/methods/sets.rb
Overview
Methods for managing Redis sets.
Instance Method Summary collapse
-
#sadd(*arguments) ⇒ Object
Add one or more members to a set.
-
#scard(*arguments) ⇒ Object
Get the number of members in a set.
-
#sdiff(*arguments) ⇒ Object
Subtract multiple sets.
-
#sdiffstore(*arguments) ⇒ Object
Subtract multiple sets and store the resulting set in a key.
-
#sinter(*arguments) ⇒ Object
Intersect multiple sets.
-
#sinterstore(*arguments) ⇒ Object
Intersect multiple sets and store the resulting set in a key.
-
#sismember(*arguments) ⇒ Object
Determine if a given value is a member of a set.
-
#smembers(*arguments) ⇒ Object
Get all the members in a set.
-
#smove(*arguments) ⇒ Object
Move a member from one set to another.
-
#spop(*arguments) ⇒ Object
Remove and return one or multiple random members from a set.
-
#srandmember(*arguments) ⇒ Object
Get one or multiple random members from a set.
-
#srem(*arguments) ⇒ Object
Remove one or more members from a set.
-
#sscan(*arguments) ⇒ Object
Incrementally iterate Set elements.
-
#sunion(*arguments) ⇒ Object
Add multiple sets.
-
#sunionstore(*arguments) ⇒ Object
Add multiple sets and store the resulting set in a key.
Instance Method Details
#sadd(*arguments) ⇒ Object
Add one or more members to a set. O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments. See <redis.io/commands/sadd> for more details.
15 16 17 |
# File 'lib/protocol/redis/methods/sets.rb', line 15 def sadd(*arguments) call("SADD", *arguments) end |
#scard(*arguments) ⇒ Object
Get the number of members in a set. O(1). See <redis.io/commands/scard> for more details.
22 23 24 |
# File 'lib/protocol/redis/methods/sets.rb', line 22 def scard(*arguments) call("SCARD", *arguments) end |
#sdiff(*arguments) ⇒ Object
Subtract multiple sets. O(N) where N is the total number of elements in all given sets. See <redis.io/commands/sdiff> for more details.
29 30 31 |
# File 'lib/protocol/redis/methods/sets.rb', line 29 def sdiff(*arguments) call("SDIFF", *arguments) end |
#sdiffstore(*arguments) ⇒ Object
Subtract multiple sets and store the resulting set in a key. O(N) where N is the total number of elements in all given sets. See <redis.io/commands/sdiffstore> for more details.
37 38 39 |
# File 'lib/protocol/redis/methods/sets.rb', line 37 def sdiffstore(*arguments) call("SDIFFSTORE", *arguments) end |
#sinter(*arguments) ⇒ Object
Intersect multiple sets. O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets. See <redis.io/commands/sinter> for more details.
44 45 46 |
# File 'lib/protocol/redis/methods/sets.rb', line 44 def sinter(*arguments) call("SINTER", *arguments) end |
#sinterstore(*arguments) ⇒ Object
Intersect multiple sets and store the resulting set in a key. O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets. See <redis.io/commands/sinterstore> for more details.
52 53 54 |
# File 'lib/protocol/redis/methods/sets.rb', line 52 def sinterstore(*arguments) call("SINTERSTORE", *arguments) end |
#sismember(*arguments) ⇒ Object
Determine if a given value is a member of a set. O(1). See <redis.io/commands/sismember> for more details.
60 61 62 |
# File 'lib/protocol/redis/methods/sets.rb', line 60 def sismember(*arguments) call("SISMEMBER", *arguments) end |
#smembers(*arguments) ⇒ Object
Get all the members in a set. O(N) where N is the set cardinality. See <redis.io/commands/smembers> for more details.
67 68 69 |
# File 'lib/protocol/redis/methods/sets.rb', line 67 def smembers(*arguments) call("SMEMBERS", *arguments) end |
#smove(*arguments) ⇒ Object
Move a member from one set to another. O(1). See <redis.io/commands/smove> for more details.
76 77 78 |
# File 'lib/protocol/redis/methods/sets.rb', line 76 def smove(*arguments) call("SMOVE", *arguments) end |
#spop(*arguments) ⇒ Object
Remove and return one or multiple random members from a set. O(1). See <redis.io/commands/spop> for more details.
84 85 86 |
# File 'lib/protocol/redis/methods/sets.rb', line 84 def spop(*arguments) call("SPOP", *arguments) end |
#srandmember(*arguments) ⇒ Object
Get one or multiple random members from a set. Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count. See <redis.io/commands/srandmember> for more details.
92 93 94 |
# File 'lib/protocol/redis/methods/sets.rb', line 92 def srandmember(*arguments) call("SRANDMEMBER", *arguments) end |
#srem(*arguments) ⇒ Object
Remove one or more members from a set. O(N) where N is the number of members to be removed. See <redis.io/commands/srem> for more details.
100 101 102 |
# File 'lib/protocol/redis/methods/sets.rb', line 100 def srem(*arguments) call("SREM", *arguments) end |
#sscan(*arguments) ⇒ Object
Incrementally iterate Set elements. O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.. See <redis.io/commands/sscan> for more details.
123 124 125 |
# File 'lib/protocol/redis/methods/sets.rb', line 123 def sscan(*arguments) call("SSCAN", *arguments) end |
#sunion(*arguments) ⇒ Object
Add multiple sets. O(N) where N is the total number of elements in all given sets. See <redis.io/commands/sunion> for more details.
107 108 109 |
# File 'lib/protocol/redis/methods/sets.rb', line 107 def sunion(*arguments) call("SUNION", *arguments) end |
#sunionstore(*arguments) ⇒ Object
Add multiple sets and store the resulting set in a key. O(N) where N is the total number of elements in all given sets. See <redis.io/commands/sunionstore> for more details.
115 116 117 |
# File 'lib/protocol/redis/methods/sets.rb', line 115 def sunionstore(*arguments) call("SUNIONSTORE", *arguments) end |