Module: Protocol::Redis::Methods::Sets

Defined in:
lib/protocol/redis/methods/sets.rb

Instance Method Summary collapse

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.

Parameters:

  • key (Key)
  • member (String)

See Also:



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).

Parameters:

  • key (Key)

See Also:



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.

Parameters:

  • key (Key)

See Also:



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.

Parameters:

  • destination (Key)
  • key (Key)

See Also:



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.

Parameters:

  • key (Key)

See Also:



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.

Parameters:

  • destination (Key)
  • key (Key)

See Also:



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).

Parameters:

  • key (Key)
  • member (String)

See Also:



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.

Parameters:

  • key (Key)

See Also:



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).

Parameters:

  • source (Key)
  • destination (Key)
  • member (String)

See Also:



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).

Parameters:

  • key (Key)
  • count (Integer)

See Also:



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.

Parameters:

  • key (Key)
  • count (Integer)

See Also:



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.

Parameters:

  • key (Key)
  • member (String)

See Also:



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..

Parameters:

  • key (Key)
  • cursor (Integer)

See Also:



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.

Parameters:

  • key (Key)

See Also:



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.

Parameters:

  • destination (Key)
  • key (Key)

See Also:



131
132
133
# File 'lib/protocol/redis/methods/sets.rb', line 131

def sunionstore(*arguments)
	call("SUNIONSTORE", *arguments)
end