Interface SetOperations<K,V>
@NullUnmarked
public interface SetOperations<K,V>
Redis set specific operations.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch, Roman Bezpalko, Mingi Lee
-
Method Summary
Modifier and TypeMethodDescriptionAdd givenvaluesto set atkey.difference(@NonNull K key, @NonNull K otherKey) Diff all sets for givenkeyandotherKey.difference(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys) Diff all sets for givenkeyandotherKeys.difference(@NonNull Collection<@NonNull K> keys) Diff all sets for givenkeys.differenceAndStore(@NonNull K key, @NonNull K otherKey, @NonNull K destKey) Diff all sets for givenkeyandotherKeyand store result indestKey.differenceAndStore(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys, @NonNull K destKey) Diff all sets for givenkeyandotherKeysand store result indestKey.differenceAndStore(@NonNull Collection<@NonNull K> keys, @NonNull K destKey) Diff all sets for givenkeysand store result indestKey.distinctRandomMembers(@NonNull K key, long count) Getcountdistinct random elements from set atkey.@NonNull RedisOperations<K, V> Returns the members intersecting all given sets atkeyandotherKey.intersect(@NonNull K key, @NonNull Collection<K> otherKeys) Returns the members intersecting all given sets atkeyandotherKeys.intersect(@NonNull Collection<K> keys) Returns the members intersecting all given sets atkeys.intersectAndStore(@NonNull K key, @NonNull K otherKey, @NonNull K destKey) Intersect all given sets atkeyandotherKeyand store result indestKey.intersectAndStore(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys, @NonNull K destKey) Intersect all given sets atkeyandotherKeysand store result indestKey.intersectAndStore(@NonNull Collection<@NonNull K> keys, @NonNull K destKey) Intersect all given sets atkeysand store result indestKey.intersectSize(@NonNull K key, @NonNull K otherKey) Returns the cardinality of the set which would result from the intersection ofkeyandotherKey.intersectSize(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys) Returns the cardinality of the set which would result from the intersection ofkeyandotherKeys.intersectSize(@NonNull Collection<@NonNull K> keys) Returns the cardinality of the set which would result from the intersection of all given sets atkeys.Check if set atkeycontainsvalue.Check if set atkeycontains one or morevalues.Get all elements of set atkey.MovevaluefromkeytodestKeyRemove and return a random member from set atkey.Remove and returncountrandom members from set atkey.randomMember(@NonNull K key) Get random element from set atkey.randomMembers(@NonNull K key, long count) Getcountrandom elements from set atkey.Remove givenvaluesfrom set atkeyand return the number of removed elements.scan(@NonNull K key, @NonNull ScanOptions options) Use aCursorto iterate over entries set atkey.Get size of set atkey.Union all sets at givenkeysandotherKey.union(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys) Union all sets at givenkeysandotherKeys.union(@NonNull Collection<@NonNull K> keys) Union all sets at givenkeys.unionAndStore(@NonNull K key, @NonNull K otherKey, @NonNull K destKey) Union all sets at givenkeyandotherKeyand store result indestKey.unionAndStore(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys, @NonNull K destKey) Union all sets at givenkeyandotherKeysand store result indestKey.unionAndStore(@NonNull Collection<@NonNull K> keys, @NonNull K destKey) Union all sets at givenkeysand store result indestKey.
-
Method Details
-
add
-
remove
-
pop
-
pop
-
move
-
size
-
isMember
-
isMember
-
intersect
-
intersect
Returns the members intersecting all given sets atkeyandotherKeys.- 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 atkeyandotherKeyand 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
Long intersectAndStore(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys, @NonNull K destKey) Intersect all given sets atkeyandotherKeysand 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 atkeysand 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:
-
intersectSize
-
intersectSize
Returns the cardinality of the set which would result from the intersection ofkeyandotherKeys.- Parameters:
key- must not be null.otherKeys- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 4.0
- See Also:
-
intersectSize
Returns the cardinality of the set which would result from the intersection of all given sets atkeys.- Parameters:
keys- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 4.0
- See Also:
-
union
-
union
Union all sets at givenkeysandotherKeys.- 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
-
unionAndStore
Union all sets at givenkeyandotherKeysand 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 givenkeysand 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
-
difference
Diff all sets for givenkeyandotherKeys.- 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 givenkeyandotherKeyand 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
Long differenceAndStore(@NonNull K key, @NonNull Collection<@NonNull K> otherKeys, @NonNull K destKey) Diff all sets for givenkeyandotherKeysand 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 givenkeysand 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
-
randomMember
-
distinctRandomMembers
Getcountdistinct random elements from set atkey.- Parameters:
key- must not be null.count- nr of members to return- Returns:
- empty
Setifkeydoes not exist. - Throws:
IllegalArgumentException- if count is negative.- See Also:
-
randomMembers
Getcountrandom elements from set atkey.- Parameters:
key- must not be null.count- nr of members to return.- Returns:
- empty
Listifkeydoes not exist or null when used in pipeline / transaction. - Throws:
IllegalArgumentException- if count is negative.- See Also:
-
scan
Use aCursorto 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
@NonNull RedisOperations<K,V> getOperations()- Returns:
- the underlying
RedisOperationsused to execute commands.
-