Module: Protocol::Redis::Methods::Sets
- Defined in:
- lib/protocol/redis/methods/sets.rb
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.
| 31 32 33 | # File 'lib/protocol/redis/methods/sets.rb', line 31 def sadd(*arguments) call("SADD", *arguments) end | 
#scard(*arguments) ⇒ Object
Get the number of members in a set. O(1).
| 38 39 40 | # File 'lib/protocol/redis/methods/sets.rb', line 38 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.
| 45 46 47 | # File 'lib/protocol/redis/methods/sets.rb', line 45 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.
| 53 54 55 | # File 'lib/protocol/redis/methods/sets.rb', line 53 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.
| 60 61 62 | # File 'lib/protocol/redis/methods/sets.rb', line 60 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.
| 68 69 70 | # File 'lib/protocol/redis/methods/sets.rb', line 68 def sinterstore(*arguments) call("SINTERSTORE", *arguments) end | 
#sismember(*arguments) ⇒ Object
Determine if a given value is a member of a set. O(1).
| 76 77 78 | # File 'lib/protocol/redis/methods/sets.rb', line 76 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.
| 83 84 85 | # File 'lib/protocol/redis/methods/sets.rb', line 83 def smembers(*arguments) call("SMEMBERS", *arguments) end | 
#smove(*arguments) ⇒ Object
Move a member from one set to another. O(1).
| 92 93 94 | # File 'lib/protocol/redis/methods/sets.rb', line 92 def smove(*arguments) call("SMOVE", *arguments) end | 
#spop(*arguments) ⇒ Object
Remove and return one or multiple random members from a set. O(1).
| 100 101 102 | # File 'lib/protocol/redis/methods/sets.rb', line 100 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.
| 108 109 110 | # File 'lib/protocol/redis/methods/sets.rb', line 108 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.
| 116 117 118 | # File 'lib/protocol/redis/methods/sets.rb', line 116 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..
| 139 140 141 | # File 'lib/protocol/redis/methods/sets.rb', line 139 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.
| 123 124 125 | # File 'lib/protocol/redis/methods/sets.rb', line 123 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.
| 131 132 133 | # File 'lib/protocol/redis/methods/sets.rb', line 131 def sunionstore(*arguments) call("SUNIONSTORE", *arguments) end |