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
public interface RSet<V> extends Set<V>, RExpirable, RSetAsync<V>, RSortable<Set<V>>
Redis based implementation ofSet
- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
addAllCounted(Collection<? extends V> c)
Adds all elements contained in the specified collection.Integer
countIntersection(int limit, String... names)
Counts elements of set as a result of sets intersection with current set.Integer
countIntersection(String... names)
Counts elements of set as a result of sets intersection with current set.int
diff(String... names)
Diff sets specified by name and write to current set.Iterator<V>
distributedIterator(int count)
Returns element iterator that can be shared across multiple applications.Iterator<V>
distributedIterator(String pattern)
Returns iterator over elements that match specified pattern.Iterator<V>
distributedIterator(String iteratorName, String pattern, int count)
Returns iterator over elements that match specified pattern.RCountDownLatch
getCountDownLatch(V value)
ReturnsRCountDownLatch
instance associated withvalue
RLock
getFairLock(V value)
ReturnsRLock
instance associated withvalue
RLock
getLock(V value)
Returns lock instance associated withvalue
RPermitExpirableSemaphore
getPermitExpirableSemaphore(V value)
ReturnsRPermitExpirableSemaphore
instance associated withvalue
RReadWriteLock
getReadWriteLock(V value)
ReturnsRReadWriteLock
instance associated withvalue
RSemaphore
getSemaphore(V value)
ReturnsRSemaphore
instance associated withvalue
int
intersection(String... names)
Intersection sets specified by name and write to current set.Iterator<V>
iterator(int count)
Returns elements iterator fetches elements in a batch.Iterator<V>
iterator(String pattern)
Returns elements iterator.Iterator<V>
iterator(String pattern, int count)
Returns elements iterator fetches elements in a batch.<KOut,VOut>
RCollectionMapReduce<V,KOut,VOut>mapReduce()
ReturnsRMapReduce
object associated with this objectboolean
move(String destination, V member)
Move a member from this set to the given destination set in.V
random()
Returns random elementSet<V>
random(int count)
Returns random elements from set limited bycount
Set<V>
readAll()
Read all elements at onceSet<V>
readDiff(String... names)
Diff sets specified by name with current set.Set<V>
readIntersection(String... names)
Intersection sets specified by name with current set without current set state change.Set<V>
readUnion(String... names)
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.V
removeRandom()
Removes and returns random elementSet<V>
removeRandom(int amount)
Removes and returns random elements limited byamount
Stream<V>
stream(int count)
Returns stream of elements fetches elements in a batch.Stream<V>
stream(String pattern)
Returns stream of elements.Stream<V>
stream(String pattern, int count)
Returns stream of elements fetches elements in a batch.boolean
tryAdd(V... values)
Tries to add elements only if none of them in set.int
union(String... names)
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, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, 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, 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 Detail
-
addAllCounted
int addAllCounted(Collection<? extends V> c)
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
int removeAllCounted(Collection<? extends V> c)
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
RCountDownLatch getCountDownLatch(V value)
ReturnsRCountDownLatch
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RCountDownLatch object
-
getPermitExpirableSemaphore
RPermitExpirableSemaphore getPermitExpirableSemaphore(V value)
ReturnsRPermitExpirableSemaphore
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RPermitExpirableSemaphore object
-
getSemaphore
RSemaphore getSemaphore(V value)
ReturnsRSemaphore
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RSemaphore object
-
getFairLock
RLock getFairLock(V value)
ReturnsRLock
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RLock object
-
getReadWriteLock
RReadWriteLock getReadWriteLock(V value)
ReturnsRReadWriteLock
instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RReadWriteLock object
-
getLock
RLock getLock(V value)
Returns lock instance associated withvalue
- Parameters:
value
- - set value- Returns:
- RLock object
-
stream
Stream<V> stream(int count)
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
Stream<V> stream(String pattern, int count)
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
Stream<V> stream(String pattern)
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
Iterator<V> iterator(int count)
Returns elements iterator fetches elements in a batch. Batch size is defined bycount
param.- Parameters:
count
- - size of elements batch- Returns:
- iterator
-
iterator
Iterator<V> iterator(String pattern, int count)
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
Iterator<V> iterator(String pattern)
Returns elements iterator. Ifpattern
is not null then only elements match this pattern are loaded.- Parameters:
pattern
- - search pattern- Returns:
- iterator
-
distributedIterator
Iterator<V> distributedIterator(int count)
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
Iterator<V> distributedIterator(String pattern)
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
Iterator<V> distributedIterator(String iteratorName, String pattern, int count)
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
<KOut,VOut> RCollectionMapReduce<V,KOut,VOut> mapReduce()
ReturnsRMapReduce
object associated with this object- Type Parameters:
KOut
- output keyVOut
- output value- Returns:
- MapReduce instance
-
removeRandom
Set<V> removeRandom(int amount)
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
Set<V> random(int count)
Returns random elements from set limited bycount
- Parameters:
count
- - values amount to return- Returns:
- random elements
-
move
boolean move(String destination, V member)
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
-
union
int union(String... names)
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
Set<V> readUnion(String... names)
Union sets specified by name with current set without current set state change.- Parameters:
names
- - name of sets- Returns:
- values
-
diff
int diff(String... names)
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
Set<V> readDiff(String... names)
Diff sets specified by name with current set. Without current set state change.- Parameters:
names
- - name of sets- Returns:
- values
-
intersection
int intersection(String... names)
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
Set<V> readIntersection(String... names)
Intersection sets specified by name with current set without current set state change.- Parameters:
names
- - name of sets- Returns:
- values
-
countIntersection
Integer countIntersection(String... names)
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
Integer countIntersection(int limit, String... names)
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
boolean tryAdd(V... values)
Tries to add elements only if none of them in set.- Parameters:
values
- - values to add- Returns:
true
if elements successfully added, otherwisefalse
.
-
-