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
public interface RSetCache<V> extends Set<V>, RExpirable, RSetCacheAsync<V>, RDestroyable
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
add(V value, long ttl, TimeUnit unit)
Stores value with specified time to live.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
Iterator<V>
iterator(int count)
Returns an iterator over elements in this set.Iterator<V>
iterator(String pattern)
Returns values iterator matchespattern
.Iterator<V>
iterator(String pattern, int count)
Returns an iterator over elements in this set.<KOut,VOut>
RCollectionMapReduce<V,KOut,VOut>mapReduce()
ReturnsRMapReduce
object associated with this mapSet<V>
readAll()
Read all elements at onceint
size()
Returns the number of elements in cache.Stream<V>
stream(int count)
Returns stream of elements in this set.Stream<V>
stream(String pattern)
Returns stream of elements in this set matchespattern
.Stream<V>
stream(String pattern, int count)
Returns stream of elements in this set.boolean
tryAdd(long ttl, TimeUnit unit, V... values)
Tries to add elements only if none of them in set.boolean
tryAdd(V... values)
Tries to add elements only if none of them in 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
-
Methods inherited from interface org.redisson.api.RDestroyable
destroy
-
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.RSetCacheAsync
addAsync, readAllAsync, sizeAsync, tryAddAsync, tryAddAsync
-
-
-
-
Method Detail
-
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 in this set. Elements are loaded in 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 in this set. Elements are loaded in 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 in this set matchespattern
.- Parameters:
pattern
- - search pattern- Returns:
- stream of elements
-
iterator
Iterator<V> iterator(int count)
Returns an iterator over elements in this set. Elements are loaded in batch. Batch size is defined bycount
param.- Parameters:
count
- - size of elements batch- Returns:
- iterator
-
iterator
Iterator<V> iterator(String pattern, int count)
Returns an iterator over elements in this set. Elements are loaded in 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 values iterator matchespattern
.- Parameters:
pattern
- - search pattern- Returns:
- iterator
-
mapReduce
<KOut,VOut> RCollectionMapReduce<V,KOut,VOut> mapReduce()
ReturnsRMapReduce
object associated with this map- Type Parameters:
KOut
- output keyVOut
- output value- Returns:
- MapReduce instance
-
add
boolean add(V value, long ttl, TimeUnit unit)
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. If0
then stores infinitely.unit
- - time unit- Returns:
true
if value has been added.false
if 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.
-
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
.
-
-