Package org.redisson
Class RedissonDelayedQueue<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonDelayedQueue<V>
-
- Type Parameters:
V- value type
- All Implemented Interfaces:
Iterable<V>,Collection<V>,Queue<V>,RCollectionAsync<V>,RDelayedQueue<V>,RDestroyable,RExpirable,RExpirableAsync,RObject,RObjectAsync,RQueue<V>,RQueueAsync<V>
public class RedissonDelayedQueue<V> extends RedissonObject implements RDelayedQueue<V>
- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRedissonDelayedQueue(QueueTransferService queueTransferService, Codec codec, CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(V e)booleanaddAll(Collection<? extends V> c)RFuture<Boolean>addAllAsync(Collection<? extends V> c)Adds all elements contained in the specified collectionRFuture<Boolean>addAsync(V e)Adds element into this collection.voidclear()booleanclearExpire()Clear an expire timeout or expire date for object.RFuture<Boolean>clearExpireAsync()Clear an expire timeout or expire date for object in async mode.protected RFuture<Boolean>clearExpireAsync(String... keys)booleancontains(Object o)booleancontainsAll(Collection<?> c)RFuture<Boolean>containsAllAsync(Collection<?> c)Returnstrueif this collection contains all of the elements in the specified collection.RFuture<Boolean>containsAsync(Object o)Returnstrueif this collection contains encoded state of the specified element.RFuture<Boolean>deleteAsync()Delete object in async modevoiddestroy()Destroys object when it's not necessary anymore.Velement()booleanexpire(long timeToLive, TimeUnit timeUnit)Set a timeout for object.booleanexpire(Instant instant)Set an expire date for object.RFuture<Boolean>expireAsync(long timeToLive, TimeUnit timeUnit)Set a timeout for object in async mode.protected RFuture<Boolean>expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)RFuture<Boolean>expireAsync(Instant instant)Set an expire date for object.booleanexpireAt(long timestamp)UseRExpirable.expire(Instant)insteadbooleanexpireAt(Date timestamp)UseRExpirable.expire(Instant)insteadRFuture<Boolean>expireAtAsync(long timestamp)UseRExpirableAsync.expireAsync(Instant)insteadprotected RFuture<Boolean>expireAtAsync(long timestamp, String... keys)RFuture<Boolean>expireAtAsync(Date timestamp)UseRExpirableAsync.expireAsync(Instant)insteadbooleanisEmpty()Iterator<V>iterator()booleanoffer(V e)voidoffer(V e, long delay, TimeUnit timeUnit)Inserts element into this queue with specified transfer delay to destination queue.RFuture<Boolean>offerAsync(V e)Inserts the specified element into this queue.RFuture<Void>offerAsync(V e, long delay, TimeUnit timeUnit)Inserts element into this queue with specified transfer delay to destination queue.Vpeek()RFuture<V>peekAsync()Retrieves the head of this queue in async mode.Vpoll()List<V>poll(int limit)Retrieves and removes the head elements of this queue.RFuture<V>pollAsync()Retrieves and removes the head of this queue in async mode.RFuture<List<V>>pollAsync(int limit)Retrieves and removes the head elements of this queue.VpollLastAndOfferFirstTo(String dequeName)Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName.RFuture<V>pollLastAndOfferFirstToAsync(String queueName)Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName.List<V>readAll()Returns all queue elements at onceRFuture<List<V>>readAllAsync()Returns all queue elements at oncelongremainTimeToLive()Remaining time to live of Redisson object that has a timeoutRFuture<Long>remainTimeToLiveAsync()Remaining time to live of Redisson object that has a timeoutVremove()booleanremove(Object o)booleanremoveAll(Collection<?> c)RFuture<Boolean>removeAllAsync(Collection<?> c)Removes all of this collection's elements that are also contained in the specified collection.RFuture<Boolean>removeAsync(Object o)Removes a single instance of the specified element from this collection, if it is present.protected RFuture<Boolean>removeAsync(Object o, int count)booleanretainAll(Collection<?> c)RFuture<Boolean>retainAllAsync(Collection<?> c)Retains only the elements in this collection that are contained in the specified collection.intsize()RFuture<Integer>sizeAsync()Returns number of elements in this collection.RFuture<Long>sizeInMemoryAsync()Returns bytes amount used by object in Redis memory.Object[]toArray()<T> T[]toArray(T[] a)-
Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListenerAsync, removeListenersAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObject
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
copyAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
-
Methods inherited from interface org.redisson.api.RQueue
addListener
-
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync
-
-
-
-
Constructor Detail
-
RedissonDelayedQueue
protected RedissonDelayedQueue(QueueTransferService queueTransferService, Codec codec, CommandAsyncExecutor commandExecutor, String name)
-
-
Method Detail
-
offer
public void offer(V e, long delay, TimeUnit timeUnit)
Description copied from interface:RDelayedQueueInserts element into this queue with specified transfer delay to destination queue.- Specified by:
offerin interfaceRDelayedQueue<V>- Parameters:
e- the element to adddelay- for transitiontimeUnit- for delay
-
offerAsync
public RFuture<Void> offerAsync(V e, long delay, TimeUnit timeUnit)
Description copied from interface:RDelayedQueueInserts element into this queue with specified transfer delay to destination queue.- Specified by:
offerAsyncin interfaceRDelayedQueue<V>- Parameters:
e- the element to adddelay- for transitiontimeUnit- for delay- Returns:
- void
-
add
public boolean add(V e)
-
size
public int size()
- Specified by:
sizein interfaceCollection<V>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<V>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<V>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<V>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfaceCollection<V>
-
readAll
public List<V> readAll()
Description copied from interface:RQueueReturns all queue elements at once
-
poll
public List<V> poll(int limit)
Description copied from interface:RQueueRetrieves and removes the head elements of this queue. Elements amount limited bylimitparam.
-
readAllAsync
public RFuture<List<V>> readAllAsync()
Description copied from interface:RQueueAsyncReturns all queue elements at once- Specified by:
readAllAsyncin interfaceRQueueAsync<V>- Returns:
- elements
-
pollAsync
public RFuture<List<V>> pollAsync(int limit)
Description copied from interface:RQueueAsyncRetrieves and removes the head elements of this queue. Elements amount limited bylimitparam.- Specified by:
pollAsyncin interfaceRQueueAsync<V>- Returns:
- list of head elements
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<V>
-
removeAsync
public RFuture<Boolean> removeAsync(Object o)
Description copied from interface:RCollectionAsyncRemoves a single instance of the specified element from this collection, if it is present.- Specified by:
removeAsyncin interfaceRCollectionAsync<V>- Parameters:
o- element to be removed from this collection, if present- Returns:
trueif an element was removed as a result of this call
-
containsAllAsync
public RFuture<Boolean> containsAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsyncReturnstrueif this collection contains all of the elements in the specified collection.- Specified by:
containsAllAsyncin interfaceRCollectionAsync<V>- Parameters:
c- collection to be checked for containment in this collection- Returns:
trueif this collection contains all of the elements in the specified collection
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<V>
-
addAll
public boolean addAll(Collection<? extends V> c)
- Specified by:
addAllin interfaceCollection<V>
-
removeAllAsync
public RFuture<Boolean> removeAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsyncRemoves all of this collection's elements that are also contained in the specified collection.- Specified by:
removeAllAsyncin interfaceRCollectionAsync<V>- Parameters:
c- collection containing elements to be removed from this collection- Returns:
trueif this collection changed as a result of the call
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<V>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<V>
-
retainAllAsync
public RFuture<Boolean> retainAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsyncRetains only the elements in this collection that are contained in the specified collection.- Specified by:
retainAllAsyncin interfaceRCollectionAsync<V>- Parameters:
c- collection containing elements to be retained in this collection- Returns:
trueif this collection changed as a result of the call
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<V>
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif not
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsyncReturns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsyncin interfaceRObjectAsync- Overrides:
sizeInMemoryAsyncin classRedissonObject- Returns:
- size in bytes
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsyncSet a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsyncClear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsyncin interfaceRExpirableAsync- Returns:
trueif the timeout was cleared andfalseif not
-
peekAsync
public RFuture<V> peekAsync()
Description copied from interface:RQueueAsyncRetrieves the head of this queue in async mode.- Specified by:
peekAsyncin interfaceRQueueAsync<V>- Returns:
- the head of this queue, or
null
-
pollAsync
public RFuture<V> pollAsync()
Description copied from interface:RQueueAsyncRetrieves and removes the head of this queue in async mode.- Specified by:
pollAsyncin interfaceRQueueAsync<V>- Returns:
- the head of this queue, or
null
-
offerAsync
public RFuture<Boolean> offerAsync(V e)
Description copied from interface:RQueueAsyncInserts the specified element into this queue.- Specified by:
offerAsyncin interfaceRQueueAsync<V>- Parameters:
e- the element to add- Returns:
trueif successful, orfalse
-
pollLastAndOfferFirstToAsync
public RFuture<V> pollLastAndOfferFirstToAsync(String queueName)
Description copied from interface:RQueueAsyncRetrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName.- Specified by:
pollLastAndOfferFirstToAsyncin interfaceRQueueAsync<V>- Parameters:
queueName- - names of destination queue- Returns:
- the tail of this queue, or
nullif the specified waiting time elapses before an element is available
-
containsAsync
public RFuture<Boolean> containsAsync(Object o)
Description copied from interface:RCollectionAsyncReturnstrueif this collection contains encoded state of the specified element.- Specified by:
containsAsyncin interfaceRCollectionAsync<V>- Parameters:
o- element whose presence in this collection is to be tested- Returns:
trueif this collection contains the specified element andfalseotherwise
-
sizeAsync
public RFuture<Integer> sizeAsync()
Description copied from interface:RCollectionAsyncReturns number of elements in this collection.- Specified by:
sizeAsyncin interfaceRCollectionAsync<V>- Returns:
- size of collection
-
addAsync
public RFuture<Boolean> addAsync(V e)
Description copied from interface:RCollectionAsyncAdds element into this collection.- Specified by:
addAsyncin interfaceRCollectionAsync<V>- Parameters:
e- - element to add- Returns:
trueif an element was added andfalseif it is already present
-
addAllAsync
public RFuture<Boolean> addAllAsync(Collection<? extends V> c)
Description copied from interface:RCollectionAsyncAdds all elements contained in the specified collection- Specified by:
addAllAsyncin interfaceRCollectionAsync<V>- Parameters:
c- - collection of elements to add- Returns:
trueif at least one element was added andfalseif all elements are already present
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String dequeName)
Description copied from interface:RQueueRetrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName.- Specified by:
pollLastAndOfferFirstToin interfaceRQueue<V>- Parameters:
dequeName- - names of destination queue- Returns:
- the tail of this queue, or
nullif the specified waiting time elapses before an element is available
-
destroy
public void destroy()
Description copied from interface:RDestroyableDestroys object when it's not necessary anymore.- Specified by:
destroyin interfaceRDestroyable
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)Description copied from interface:RExpirableSet a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirableSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
Description copied from interface:RExpirableAsyncSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirableClear an expire timeout or expire date for object.- Specified by:
clearExpirein interfaceRExpirable- Returns:
trueif timeout was removedfalseif object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirableRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLivein interfaceRExpirable- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
public RFuture<Long> remainTimeToLiveAsync()
Description copied from interface:RExpirableAsyncRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsyncin interfaceRExpirableAsync- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
expireAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
-
-