Package org.redisson.api
Interface RSet<V>
- Type Parameters:
V
- type of value
- All Superinterfaces:
Collection<V>
,Iterable<V>
,RCollectionAsync<V>
,RExpirable
,RExpirableAsync
,RObject
,RObjectAsync
,RSetAsync<V>
,RSortable<Set<V>>
,RSortableAsync<Set<V>>
,Set<V>
- All Known Implementing Classes:
RedissonSet
,RedissonSetMultimapValues
,RedissonTransactionalSet
Redis based implementation of
Set
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionint
addAllCounted
(Collection<? extends V> c) Adds all elements contained in the specified collection.containsEach
(Collection<V> c) Check if each element is contained in the specified collection.countIntersection
(int limit, String... names) Counts elements of set as a result of sets intersection with current set.countIntersection
(String... names) Counts elements of set as a result of sets intersection with current set.int
Diff sets specified by name and write to current set.distributedIterator
(int count) Returns element iterator that can be shared across multiple applications.distributedIterator
(String pattern) Returns iterator over elements that match specified pattern.distributedIterator
(String iteratorName, String pattern, int count) Returns iterator over elements that match specified pattern.getCountDownLatch
(V value) ReturnsRCountDownLatch
instance associated withvalue
getFairLock
(V value) ReturnsRLock
instance associated withvalue
Returns lock instance associated withvalue
getPermitExpirableSemaphore
(V value) ReturnsRPermitExpirableSemaphore
instance associated withvalue
getReadWriteLock
(V value) ReturnsRReadWriteLock
instance associated withvalue
getSemaphore
(V value) ReturnsRSemaphore
instance associated withvalue
int
intersection
(String... names) Intersection sets specified by name and write to current set.iterator
(int count) Returns elements iterator fetches elements in a batch.Returns elements iterator.Returns elements iterator fetches elements in a batch.<KOut,
VOut>
RCollectionMapReduce<V,KOut, VOut> ReturnsRMapReduce
object associated with this objectboolean
Move a member from this set to the given destination set in.random()
Returns random elementrandom
(int count) Returns random elements from set limited bycount
readAll()
Read all elements at onceDiff sets specified by name with current set.readIntersection
(String... names) Intersection sets specified by name with current set without current set state change.Union sets specified by name with current set without current set state change.int
removeAllCounted
(Collection<? extends V> c) Removes all elements contained in the specified collection.Removes and returns random elementremoveRandom
(int amount) Removes and returns random elements limited byamount
stream
(int count) Returns stream of elements fetches elements in a batch.Returns stream of elements.Returns stream of elements fetches elements in a batch.boolean
Tries to add elements only if none of them in set.int
Union sets specified by name and write to current set.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.redisson.api.RCollectionAsync
addAllAsync, addAsync, containsAllAsync, containsAsync, removeAllAsync, removeAsync, retainAllAsync, sizeAsync
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsync
Methods inherited from interface org.redisson.api.RObject
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
Methods inherited from interface org.redisson.api.RSetAsync
addAllCountedAsync, containsEachAsync, countIntersectionAsync, countIntersectionAsync, diffAsync, intersectionAsync, moveAsync, randomAsync, randomAsync, readAllAsync, readDiffAsync, readIntersectionAsync, readUnionAsync, removeAllCountedAsync, removeRandomAsync, removeRandomAsync, tryAddAsync, unionAsync
Methods inherited from interface org.redisson.api.RSortable
readSort, readSort, readSort, readSort, readSort, readSort, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, sortTo, sortTo, sortTo, sortTo, sortTo, sortTo
Methods inherited from interface org.redisson.api.RSortableAsync
readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync
-
Method Details
-
addAllCounted
Adds all elements contained in the specified collection. Returns number of added elements.- Parameters:
c
- - collection of elements to add- Returns:
- number of added elements
-
removeAllCounted
Removes all elements contained in the specified collection. Returns number of removed elements.- Parameters:
c
- - collection of elements to add- Returns:
- number of removed elements
-
getCountDownLatch
ReturnsRCountDownLatch
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RCountDownLatch object
-
getPermitExpirableSemaphore
ReturnsRPermitExpirableSemaphore
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RPermitExpirableSemaphore object
-
getSemaphore
ReturnsRSemaphore
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RSemaphore object
-
getFairLock
ReturnsRLock
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RLock object
-
getReadWriteLock
ReturnsRReadWriteLock
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RReadWriteLock object
-
getLock
Returns lock instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RLock object
-
stream
Returns stream of elements fetches elements in a batch. Batch size is defined bycount
param.- Parameters:
count
- - size of elements batch- Returns:
- stream of elements
-
stream
Returns stream of elements fetches elements in a batch. Batch size is defined bycount
param. If pattern is not null then only elements match this pattern are loaded.- Parameters:
pattern
- - search patterncount
- - size of elements batch- Returns:
- stream of elements
-
stream
Returns stream of elements. If pattern is not null then only elements match this pattern are loaded.- Parameters:
pattern
- - search pattern- Returns:
- stream of elements
-
iterator
Returns elements iterator fetches elements in a batch. Batch size is defined bycount
param.- Parameters:
count
- - size of elements batch- Returns:
- iterator
-
iterator
Returns elements iterator fetches elements in a batch. Batch size is defined bycount
param. If pattern is not null then only elements match this pattern are loaded.- Parameters:
pattern
- - search patterncount
- - size of elements batch- Returns:
- iterator
-
iterator
Returns elements iterator. Ifpattern
is not null then only elements match this pattern are loaded.- Parameters:
pattern
- - search pattern- Returns:
- iterator
-
distributedIterator
Returns element iterator that can be shared across multiple applications. Creating multiple iterators on the same object with this method will result in a single shared iterator. See distributedIterator(String, String, int) for creating different iterators.- Parameters:
count
- batch size- Returns:
- shared elements iterator
-
distributedIterator
Returns iterator over elements that match specified pattern. Iterator can be shared across multiple applications. Creating multiple iterators on the same object with this method will result in a single shared iterator. See distributedIterator(String, String, int) for creating different iterators.- Parameters:
pattern
- element pattern- Returns:
- shared elements iterator
-
distributedIterator
Returns iterator over elements that match specified pattern. Iterator can be shared across multiple applications. Creating multiple iterators on the same object with this method will result in a single shared iterator. Iterator name must be resolved to the same hash slot as set name.- Parameters:
pattern
- element patterncount
- batch sizeiteratorName
- redis object name to which cursor will be saved- Returns:
- shared elements iterator
-
mapReduce
ReturnsRMapReduce
object associated with this object- Type Parameters:
KOut
- output keyVOut
- output value- Returns:
- MapReduce instance
-
removeRandom
Removes and returns random elements limited byamount
- Parameters:
amount
- of random elements- Returns:
- random elements
-
removeRandom
V removeRandom()Removes and returns random element- Returns:
- random element
-
random
V random()Returns random element- Returns:
- random element
-
random
Returns random elements from set limited bycount
- Parameters:
count
- - values amount to return- Returns:
- random elements
-
move
Move a member from this set to the given destination set in.- Parameters:
destination
- the destination setmember
- the member to move- Returns:
- true if the element is moved, false if the element is not a member of this set or no operation was performed
-
readAll
Read all elements at once- Returns:
- values
-
union
Union sets specified by name and write to current set. If current set already exists, it is overwritten.- Parameters:
names
- - name of sets- Returns:
- size of union
-
readUnion
Union sets specified by name with current set without current set state change.- Parameters:
names
- - name of sets- Returns:
- values
-
diff
Diff sets specified by name and write to current set. If current set already exists, it is overwritten.- Parameters:
names
- - name of sets- Returns:
- values
-
readDiff
Diff sets specified by name with current set. Without current set state change.- Parameters:
names
- - name of sets- Returns:
- values
-
intersection
Intersection sets specified by name and write to current set. If current set already exists, it is overwritten.- Parameters:
names
- - name of sets- Returns:
- size of intersection
-
readIntersection
Intersection sets specified by name with current set without current set state change.- Parameters:
names
- - name of sets- Returns:
- values
-
countIntersection
Counts elements of set as a result of sets intersection with current set.Requires Redis 7.0.0 and higher.
- Parameters:
names
- - name of sets- Returns:
- amount of elements
-
countIntersection
Counts elements of set as a result of sets intersection with current set.Requires Redis 7.0.0 and higher.
- Parameters:
names
- - name of setslimit
- - sets intersection limit- Returns:
- amount of elements
-
tryAdd
Tries to add elements only if none of them in set.- Parameters:
values
- - values to add- Returns:
true
if elements successfully added, otherwisefalse
.
-
containsEach
Check if each element is contained in the specified collection. Returns contained elements.Requires Redis 6.2.0 and higher.
- Parameters:
c
- - collection to check- Returns:
- contained elements
-