Package org.redisson.api
Interface RSetCache<V>
- Type Parameters:
V- value
- All Superinterfaces:
Collection<V>,Iterable<V>,RCollectionAsync<V>,RDestroyable,RExpirable,RExpirableAsync,RObject,RObjectAsync,RSetCacheAsync<V>,Set<V>
- All Known Implementing Classes:
RedissonSetCache,RedissonTransactionalSetCache
Set-based cache with ability to set TTL for each object.
Current Redis implementation doesn't have set entry eviction functionality.
Thus values are checked for TTL expiration during any value read operation.
If entry expired then it doesn't returns and clean task runs asynchronous.
Clean task deletes removes 100 expired entries at once.
In addition there is EvictionScheduler. This scheduler
deletes expired entries in time interval between 5 seconds to 2 hours.
If eviction is not required then it's better to use RSet.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionbooleanStores value with specified time to live.getCountDownLatch(V value) ReturnsRCountDownLatchinstance associated withvaluegetFairLock(V value) ReturnsRLockinstance associated withvalueReturns lock instance associated withvaluegetPermitExpirableSemaphore(V value) ReturnsRPermitExpirableSemaphoreinstance associated withvaluegetReadWriteLock(V value) ReturnsRReadWriteLockinstance associated withvaluegetSemaphore(V value) ReturnsRSemaphoreinstance associated withvalueiterator(int count) Returns an iterator over elements in this set.Returns values iterator matchespattern.Returns an iterator over elements in this set.<KOut,VOut>
RCollectionMapReduce<V,KOut, VOut> ReturnsRMapReduceobject associated with this mapreadAll()Read all elements at onceintsize()Returns the number of elements in cache.stream(int count) Returns stream of elements in this set.Returns stream of elements in this set matchespattern.Returns stream of elements in this set.booleanTries to add elements only if none of them in set.booleanTries to add elements only if none of them in set.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.redisson.api.RCollectionAsync
addAllAsync, addAsync, containsAllAsync, containsAsync, removeAllAsync, removeAsync, retainAllAsyncMethods inherited from interface org.redisson.api.RDestroyable
destroyMethods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLiveMethods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsyncMethods 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, unlinkMethods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsyncMethods inherited from interface org.redisson.api.RSetCacheAsync
addAsync, readAllAsync, sizeAsync, tryAddAsync, tryAddAsync
-
Method Details
-
getCountDownLatch
ReturnsRCountDownLatchinstance associated withvalue- Parameters:
value- - set value- Returns:
- RCountDownLatch object
-
getPermitExpirableSemaphore
ReturnsRPermitExpirableSemaphoreinstance associated withvalue- Parameters:
value- - set value- Returns:
- RPermitExpirableSemaphore object
-
getSemaphore
ReturnsRSemaphoreinstance associated withvalue- Parameters:
value- - set value- Returns:
- RSemaphore object
-
getFairLock
ReturnsRLockinstance associated withvalue- Parameters:
value- - set value- Returns:
- RLock object
-
getReadWriteLock
ReturnsRReadWriteLockinstance 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 in this set. Elements are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of elements batch- Returns:
- stream of elements
-
stream
Returns stream of elements in this set. Elements are loaded in batch. Batch size is defined bycountparam. 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 in this set matchespattern.- Parameters:
pattern- - search pattern- Returns:
- stream of elements
-
iterator
Returns an iterator over elements in this set. Elements are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of elements batch- Returns:
- iterator
-
iterator
Returns an iterator over elements in this set. Elements are loaded in batch. Batch size is defined bycountparam. 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 values iterator matchespattern.- Parameters:
pattern- - search pattern- Returns:
- iterator
-
mapReduce
ReturnsRMapReduceobject associated with this map- Type Parameters:
KOut- output keyVOut- output value- Returns:
- MapReduce instance
-
add
Stores value with specified time to live. Value expires after specified time to live.- Parameters:
value- to addttl- - time to live for key\value entry. If0then stores infinitely.unit- - time unit- Returns:
trueif value has been added.falseif value already been in collection.
-
size
int size()Returns the number of elements in cache. This number can reflects expired elements too due to non realtime cleanup process. -
readAll
Read all elements at once- Returns:
- values
-
tryAdd
Tries to add elements only if none of them in set.- Parameters:
values- - values to add- Returns:
trueif elements successfully added, otherwisefalse.
-
tryAdd
Tries to add elements only if none of them in set.- Parameters:
values- - values to addttl- - time to live for value. If0then stores infinitely.unit- - time unit- Returns:
trueif elements successfully added, otherwisefalse.
-