Interface RedisSetCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection
,DefaultedRedisConnection
,RedisClusterConnection
,RedisCommands
,RedisConnection
,RedisConnectionUtils.RedisConnectionProxy
,StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection
,DefaultStringRedisConnection
,JedisClusterConnection
,JedisConnection
,LettuceClusterConnection
,LettuceConnection
public interface RedisSetCommands
Set-specific commands supported by Redis.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionsAdd
(byte[] key, byte[]... values) Add givenvalues
to set atkey
.sCard
(byte[] key) Get size of set atkey
.Set<byte[]>
sDiff
(byte[]... keys) Diff all sets for givenkeys
.sDiffStore
(byte[] destKey, byte[]... keys) Diff all sets for givenkeys
and store result indestKey
.Set<byte[]>
sInter
(byte[]... keys) Returns the members intersecting all given sets atkeys
.sInterStore
(byte[] destKey, byte[]... keys) Intersect all given sets atkeys
and store result indestKey
.sIsMember
(byte[] key, byte[] value) Check if set atkey
containsvalue
.Set<byte[]>
sMembers
(byte[] key) Get all elements of set atkey
.sMIsMember
(byte[] key, byte[]... values) Check if set atkey
contains one or morevalues
.sMove
(byte[] srcKey, byte[] destKey, byte[] value) Movevalue
fromsrcKey
todestKey
byte[]
sPop
(byte[] key) Remove and return a random member from set atkey
.List<byte[]>
sPop
(byte[] key, long count) Remove and returncount
random members from set atkey
.byte[]
sRandMember
(byte[] key) Get random element from set atkey
.List<byte[]>
sRandMember
(byte[] key, long count) Getcount
random elements from set atkey
.sRem
(byte[] key, byte[]... values) Remove givenvalues
from set atkey
and return the number of removed elements.Cursor<byte[]>
sScan
(byte[] key, ScanOptions options) Use aCursor
to iterate over elements in set atkey
.Set<byte[]>
sUnion
(byte[]... keys) Union all sets at givenkeys
.sUnionStore
(byte[] destKey, byte[]... keys) Union all sets at givenkeys
and store result indestKey
.
-
Method Details
-
sAdd
Add givenvalues
to set atkey
.- Parameters:
key
- must not be null.values
- must not be empty.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sRem
Remove givenvalues
from set atkey
and return the number of removed elements.- Parameters:
key
- must not be null.values
- must not be empty.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sPop
Remove and return a random member from set atkey
.- Parameters:
key
- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- See Also:
-
sPop
Remove and returncount
random members from set atkey
.- Parameters:
key
- must not be null.count
- number of random members to pop from the set.- Returns:
- empty
List
if set does not exist. null when used in pipeline / transaction. - Since:
- 2.0
- See Also:
-
sMove
Movevalue
fromsrcKey
todestKey
- Parameters:
srcKey
- must not be null.destKey
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sCard
Get size of set atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sIsMember
Check if set atkey
containsvalue
.- Parameters:
key
- must not be null.value
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sMIsMember
Check if set atkey
contains one or morevalues
.- Parameters:
key
- must not be null.values
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
sDiff
Diff all sets for givenkeys
.- Parameters:
keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sDiffStore
Diff all sets for givenkeys
and store result indestKey
.- Parameters:
destKey
- must not be null.keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sInter
Returns the members intersecting all given sets atkeys
.- Parameters:
keys
- must not be null.- Returns:
- empty
Set
if no intersection found. null when used in pipeline / transaction. - See Also:
-
sInterStore
Intersect all given sets atkeys
and store result indestKey
.- Parameters:
destKey
- must not be null.keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sUnion
Union all sets at givenkeys
.- Parameters:
keys
- must not be null.- Returns:
- empty
Set
if keys do not exist. null when used in pipeline / transaction. - See Also:
-
sUnionStore
Union all sets at givenkeys
and store result indestKey
.- Parameters:
destKey
- must not be null.keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sMembers
Get all elements of set atkey
.- Parameters:
key
- must not be null.- Returns:
- empty
Set
when key does not exist. null when used in pipeline / transaction. - See Also:
-
sRandMember
Get random element from set atkey
.- Parameters:
key
- must not be null.- Returns:
- can be null.
- See Also:
-
sRandMember
Getcount
random elements from set atkey
.- Parameters:
key
- must not be null.count
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
sScan
Use aCursor
to iterate over elements in set atkey
.- Parameters:
key
- must not be null.options
- must not be null.- Returns:
- never null.
- Since:
- 1.4
- See Also:
-