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 protected
RedissonDelayedQueue(QueueTransferService queueTransferService, Codec codec, CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(V e)
boolean
addAll(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.void
clear()
boolean
clearExpire()
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)
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
RFuture<Boolean>
containsAllAsync(Collection<?> c)
Returnstrue
if this collection contains all of the elements in the specified collection.RFuture<Boolean>
containsAsync(Object o)
Returnstrue
if this collection contains encoded state of the specified element.RFuture<Boolean>
deleteAsync()
Delete object in async modevoid
destroy()
Destroys object when it's not necessary anymore.V
element()
boolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.boolean
expire(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.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
expireAt(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)
insteadboolean
isEmpty()
Iterator<V>
iterator()
boolean
offer(V e)
void
offer(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.V
peek()
RFuture<V>
peekAsync()
Retrieves the head of this queue in async mode.V
poll()
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.V
pollLastAndOfferFirstTo(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 oncelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutV
remove()
boolean
remove(Object o)
boolean
removeAll(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)
boolean
retainAll(Collection<?> c)
RFuture<Boolean>
retainAllAsync(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection.int
size()
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:RDelayedQueue
Inserts element into this queue with specified transfer delay to destination queue.- Specified by:
offer
in 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:RDelayedQueue
Inserts element into this queue with specified transfer delay to destination queue.- Specified by:
offerAsync
in 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:
size
in interfaceCollection<V>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<V>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<V>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<V>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<V>
-
readAll
public List<V> readAll()
Description copied from interface:RQueue
Returns all queue elements at once
-
poll
public List<V> poll(int limit)
Description copied from interface:RQueue
Retrieves and removes the head elements of this queue. Elements amount limited bylimit
param.
-
readAllAsync
public RFuture<List<V>> readAllAsync()
Description copied from interface:RQueueAsync
Returns all queue elements at once- Specified by:
readAllAsync
in interfaceRQueueAsync<V>
- Returns:
- elements
-
pollAsync
public RFuture<List<V>> pollAsync(int limit)
Description copied from interface:RQueueAsync
Retrieves and removes the head elements of this queue. Elements amount limited bylimit
param.- Specified by:
pollAsync
in interfaceRQueueAsync<V>
- Returns:
- list of head elements
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<V>
-
removeAsync
public RFuture<Boolean> removeAsync(Object o)
Description copied from interface:RCollectionAsync
Removes a single instance of the specified element from this collection, if it is present.- Specified by:
removeAsync
in interfaceRCollectionAsync<V>
- Parameters:
o
- element to be removed from this collection, if present- Returns:
true
if an element was removed as a result of this call
-
containsAllAsync
public RFuture<Boolean> containsAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsync
Returnstrue
if this collection contains all of the elements in the specified collection.- Specified by:
containsAllAsync
in interfaceRCollectionAsync<V>
- Parameters:
c
- collection to be checked for containment in this collection- Returns:
true
if this collection contains all of the elements in the specified collection
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<V>
-
addAll
public boolean addAll(Collection<? extends V> c)
- Specified by:
addAll
in interfaceCollection<V>
-
removeAllAsync
public RFuture<Boolean> removeAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsync
Removes all of this collection's elements that are also contained in the specified collection.- Specified by:
removeAllAsync
in interfaceRCollectionAsync<V>
- Parameters:
c
- collection containing elements to be removed from this collection- Returns:
true
if this collection changed as a result of the call
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<V>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<V>
-
retainAllAsync
public RFuture<Boolean> retainAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsync
Retains only the elements in this collection that are contained in the specified collection.- Specified by:
retainAllAsync
in interfaceRCollectionAsync<V>
- Parameters:
c
- collection containing elements to be retained in this collection- Returns:
true
if this collection changed as a result of the call
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<V>
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Overrides:
deleteAsync
in classRedissonObject
- Returns:
true
if object was deletedfalse
if not
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsync
Returns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsync
in interfaceRObjectAsync
- Overrides:
sizeInMemoryAsync
in classRedissonObject
- Returns:
- size in bytes
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsync
Set a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsync
Clear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsync
in interfaceRExpirableAsync
- Returns:
true
if the timeout was cleared andfalse
if not
-
peekAsync
public RFuture<V> peekAsync()
Description copied from interface:RQueueAsync
Retrieves the head of this queue in async mode.- Specified by:
peekAsync
in interfaceRQueueAsync<V>
- Returns:
- the head of this queue, or
null
-
pollAsync
public RFuture<V> pollAsync()
Description copied from interface:RQueueAsync
Retrieves and removes the head of this queue in async mode.- Specified by:
pollAsync
in interfaceRQueueAsync<V>
- Returns:
- the head of this queue, or
null
-
offerAsync
public RFuture<Boolean> offerAsync(V e)
Description copied from interface:RQueueAsync
Inserts the specified element into this queue.- Specified by:
offerAsync
in interfaceRQueueAsync<V>
- Parameters:
e
- the element to add- Returns:
true
if successful, orfalse
-
pollLastAndOfferFirstToAsync
public RFuture<V> pollLastAndOfferFirstToAsync(String queueName)
Description copied from interface:RQueueAsync
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.- Specified by:
pollLastAndOfferFirstToAsync
in interfaceRQueueAsync<V>
- Parameters:
queueName
- - names of destination queue- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available
-
containsAsync
public RFuture<Boolean> containsAsync(Object o)
Description copied from interface:RCollectionAsync
Returnstrue
if this collection contains encoded state of the specified element.- Specified by:
containsAsync
in interfaceRCollectionAsync<V>
- Parameters:
o
- element whose presence in this collection is to be tested- Returns:
true
if this collection contains the specified element andfalse
otherwise
-
sizeAsync
public RFuture<Integer> sizeAsync()
Description copied from interface:RCollectionAsync
Returns number of elements in this collection.- Specified by:
sizeAsync
in interfaceRCollectionAsync<V>
- Returns:
- size of collection
-
addAsync
public RFuture<Boolean> addAsync(V e)
Description copied from interface:RCollectionAsync
Adds element into this collection.- Specified by:
addAsync
in interfaceRCollectionAsync<V>
- Parameters:
e
- - element to add- Returns:
true
if an element was added andfalse
if it is already present
-
addAllAsync
public RFuture<Boolean> addAllAsync(Collection<? extends V> c)
Description copied from interface:RCollectionAsync
Adds all elements contained in the specified collection- Specified by:
addAllAsync
in interfaceRCollectionAsync<V>
- Parameters:
c
- - collection of elements to add- Returns:
true
if at least one element was added andfalse
if all elements are already present
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String dequeName)
Description copied from interface:RQueue
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.- Specified by:
pollLastAndOfferFirstTo
in interfaceRQueue<V>
- Parameters:
dequeName
- - names of destination queue- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available
-
destroy
public void destroy()
Description copied from interface:RDestroyable
Destroys object when it's not necessary anymore.- Specified by:
destroy
in interfaceRDestroyable
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirable
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
Description copied from interface:RExpirableAsync
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirable
Clear an expire timeout or expire date for object.- Specified by:
clearExpire
in interfaceRExpirable
- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirable
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLive
in 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:RExpirableAsync
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsync
in 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)
-
-