Package org.redisson
Class RedissonDelayedQueue<V>
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonDelayedQueue<V>
-
- Type Parameters:
V
- value type
- All Implemented Interfaces:
<V>
,<V>
,<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, name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(V e)
boolean
<? extends V> c)
>
<? extends V> c)
Adds all elements contained in the specified collection>
addAsync(V e)
Adds element into this collection.void
clear()
boolean
clearExpire()
Clear an expire timeout or expire date for object.>
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.protected >
... keys)
boolean
o)
boolean
<?> c)
>
<?> c)
Returnstrue
if this collection contains all of the elements in the specified collection.>
o)
Returnstrue
if this collection contains encoded state of the specified element.>
deleteAsync()
Delete object in async modevoid
destroy()
Destroys object when it's not necessary anymore.V
element()
boolean
expire(long timeToLive, timeUnit)
Set a timeout for object.boolean
instant)
Set an expire date for object.>
expireAsync(long timeToLive, timeUnit)
Set a timeout for object in async mode.protected >
expireAsync(long timeToLive, timeUnit, ... keys)
>
instant)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
timestamp)
UseRExpirable.expire(Instant)
instead>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected >
expireAtAsync(long timestamp, ... keys)
>
timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadboolean
isEmpty()
<V>
iterator()
boolean
offer(V e)
void
offer(V e, long delay, timeUnit)
Inserts element into this queue with specified transfer delay to destination queue.>
offerAsync(V e)
Inserts the specified element into this queue.>
offerAsync(V e, long delay, 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()
<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.<V>>
pollAsync(int limit)
Retrieves and removes the head elements of this queue.V
dequeName)
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.RFuture<V>
queueName)
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.<V>
readAll()
Returns all queue elements at once<V>>
readAllAsync()
Returns all queue elements at oncelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeout>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutV
remove()
boolean
o)
boolean
<?> c)
>
<?> c)
Removes all of this collection's elements that are also contained in the specified collection.>
o)
Removes a single instance of the specified element from this collection, if it is present.protected >
o, int count)
boolean
<?> c)
>
<?> c)
Retains only the elements in this collection that are contained in the specified collection.int
size()
>
sizeAsync()
Returns number of elements in this collection.>
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.[]
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 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, name)
-
-
Method Detail
-
offer
public void offer(V e, long delay, 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 > offerAsync(V e, long delay, 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
-
size
public int size()
- Specified by:
in interface
<V>
-
isEmpty
public boolean isEmpty()
- Specified by:
in interface
<V>
-
contains
public boolean contains( o)
- Specified by:
in interface
<V>
-
toArray
public [] toArray()
- Specified by:
in interface
<V>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
in interface
<V>
-
readAll
public <V> readAll()
Description copied from interface:RQueue
Returns all queue elements at once
-
poll
public <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 <V>> readAllAsync()
Description copied from interface:RQueueAsync
Returns all queue elements at once- Specified by:
readAllAsync
in interfaceRQueueAsync<V>
- Returns:
- elements
-
pollAsync
public <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( o)
- Specified by:
in interface
<V>
-
removeAsync
public > removeAsync( 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
-
removeAsync
protected > removeAsync( o, int count)
-
containsAllAsync
public > containsAllAsync(<?> 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(<?> c)
- Specified by:
in interface
<V>
-
removeAllAsync
public > removeAllAsync(<?> 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(<?> c)
- Specified by:
in interface
<V>
-
retainAll
public boolean retainAll(<?> c)
- Specified by:
in interface
<V>
-
retainAllAsync
public > retainAllAsync(<?> 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:
in interface
<V>
-
deleteAsync
public > 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 > 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 > expireAsync(long timeToLive, 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
-
expireAtAsync
protected > expireAtAsync(long timestamp, ... keys)
-
clearExpireAsync
public > 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 > 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 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 > containsAsync( 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 > 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 > 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 > addAllAsync(<? 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 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)
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 > 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)
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 > expireAsync( 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( 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 > expireAtAsync( 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 > 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 > expireAsync(long timeToLive, timeUnit, ... keys)
-
clearExpireAsync
protected > clearExpireAsync(... keys)
-
-