Interface SetOperations<K,V>
public interface SetOperations<K,V>
Redis set specific operations.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch, Roman Bezpalko
-
Method Summary
Modifier and TypeMethodDescriptionAdd givenvalues
to set atkey
.difference
(Collection<K> keys) Diff all sets for givenkeys
.difference
(K key, Collection<K> otherKeys) Diff all sets for givenkey
andotherKeys
.difference
(K key, K otherKey) Diff all sets for givenkey
andotherKey
.differenceAndStore
(Collection<K> keys, K destKey) Diff all sets for givenkeys
and store result indestKey
.differenceAndStore
(K key, Collection<K> otherKeys, K destKey) Diff all sets for givenkey
andotherKeys
and store result indestKey
.differenceAndStore
(K key, K otherKey, K destKey) Diff all sets for givenkey
andotherKey
and store result indestKey
.distinctRandomMembers
(K key, long count) Getcount
distinct random elements from set atkey
.intersect
(Collection<K> keys) Returns the members intersecting all given sets atkeys
.intersect
(K key, Collection<K> otherKeys) Returns the members intersecting all given sets atkey
andotherKeys
.Returns the members intersecting all given sets atkey
andotherKey
.intersectAndStore
(Collection<K> keys, K destKey) Intersect all given sets atkeys
and store result indestKey
.intersectAndStore
(K key, Collection<K> otherKeys, K destKey) Intersect all given sets atkey
andotherKeys
and store result indestKey
.intersectAndStore
(K key, K otherKey, K destKey) Intersect all given sets atkey
andotherKey
and store result indestKey
.Check if set atkey
containsvalue
.Check if set atkey
contains one or morevalues
.Get all elements of set atkey
.Movevalue
fromkey
todestKey
Remove and return a random member from set atkey
.Remove and returncount
random members from set atkey
.randomMember
(K key) Get random element from set atkey
.randomMembers
(K key, long count) Getcount
random elements from set atkey
.Remove givenvalues
from set atkey
and return the number of removed elements.scan
(K key, ScanOptions options) Use aCursor
to iterate over entries set atkey
.Get size of set atkey
.union
(Collection<K> keys) Union all sets at givenkeys
.union
(K key, Collection<K> otherKeys) Union all sets at givenkeys
andotherKeys
.Union all sets at givenkeys
andotherKey
.unionAndStore
(Collection<K> keys, K destKey) Union all sets at givenkeys
and store result indestKey
.unionAndStore
(K key, Collection<K> otherKeys, K destKey) Union all sets at givenkey
andotherKeys
and store result indestKey
.unionAndStore
(K key, K otherKey, K destKey) Union all sets at givenkey
andotherKey
and store result indestKey
.
-
Method Details
-
add
Add givenvalues
to set atkey
.- Parameters:
key
- must not be null.values
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
remove
Remove givenvalues
from set atkey
and return the number of removed elements.- Parameters:
key
- must not be null.values
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
pop
Remove and return a random member from set atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
pop
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:
- null when used in pipeline / transaction.
- Since:
- 2.0
- See Also:
-
move
Movevalue
fromkey
todestKey
- Parameters:
key
- must not be null.value
-destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
size
Get size of set atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
isMember
Check if set atkey
containsvalue
.- Parameters:
key
- must not be null.o
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
isMember
Check if set atkey
contains one or morevalues
.- Parameters:
key
- must not be null.objects
-- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
intersect
Returns the members intersecting all given sets atkey
andotherKey
.- Parameters:
key
- must not be null.otherKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
intersect
Returns the members intersecting all given sets atkey
andotherKeys
.- Parameters:
key
- must not be null.otherKeys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
intersect
Returns the members intersecting all given sets atkeys
.- Parameters:
keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.2
- See Also:
-
intersectAndStore
Intersect all given sets atkey
andotherKey
and store result indestKey
.- Parameters:
key
- must not be null.otherKey
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
intersectAndStore
Intersect all given sets atkey
andotherKeys
and store result indestKey
.- Parameters:
key
- must not be null.otherKeys
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
intersectAndStore
Intersect all given sets atkeys
and store result indestKey
.- Parameters:
keys
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.2
- See Also:
-
union
Union all sets at givenkeys
andotherKey
.- Parameters:
key
- must not be null.otherKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
union
Union all sets at givenkeys
andotherKeys
.- Parameters:
key
- must not be null.otherKeys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
union
Union all sets at givenkeys
.- Parameters:
keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.2
- See Also:
-
unionAndStore
Union all sets at givenkey
andotherKey
and store result indestKey
.- Parameters:
key
- must not be null.otherKey
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
unionAndStore
Union all sets at givenkey
andotherKeys
and store result indestKey
.- Parameters:
key
- must not be null.otherKeys
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
unionAndStore
Union all sets at givenkeys
and store result indestKey
.- Parameters:
keys
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.2
- See Also:
-
difference
Diff all sets for givenkey
andotherKey
.- Parameters:
key
- must not be null.otherKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
difference
Diff all sets for givenkey
andotherKeys
.- Parameters:
key
- must not be null.otherKeys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
difference
Diff all sets for givenkeys
.- Parameters:
keys
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.2
- See Also:
-
differenceAndStore
Diff all sets for givenkey
andotherKey
and store result indestKey
.- Parameters:
key
- must not be null.otherKey
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
differenceAndStore
Diff all sets for givenkey
andotherKeys
and store result indestKey
.- Parameters:
key
- must not be null.otherKeys
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
differenceAndStore
Diff all sets for givenkeys
and store result indestKey
.- Parameters:
keys
- must not be null.destKey
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.2
- See Also:
-
members
Get all elements of set atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
randomMember
Get random element from set atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
distinctRandomMembers
Getcount
distinct random elements from set atkey
.- Parameters:
key
- must not be null.count
- nr of members to return- Returns:
- empty
Set
ifkey
does not exist. - Throws:
IllegalArgumentException
- if count is negative.- See Also:
-
randomMembers
Getcount
random elements from set atkey
.- Parameters:
key
- must not be null.count
- nr of members to return.- Returns:
- empty
List
ifkey
does not exist or null when used in pipeline / transaction. - Throws:
IllegalArgumentException
- if count is negative.- See Also:
-
scan
Use aCursor
to iterate over entries set atkey
.
Important: CallCloseableIterator.close()
when done to avoid resource leaks.- Parameters:
key
-options
- must not be null.- Returns:
- the result cursor providing access to the scan result. Must be closed once fully processed (e.g. through a try-with-resources clause).
- Since:
- 1.4
-
getOperations
RedisOperations<K,V> getOperations()
-