Package org.redisson
Class RedissonTransferQueue<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonTransferQueue<V>
-
- All Implemented Interfaces:
Iterable<V>
,Collection<V>
,BlockingQueue<V>
,TransferQueue<V>
,Queue<V>
,RBlockingQueue<V>
,RBlockingQueueAsync<V>
,RCollectionAsync<V>
,RExpirable
,RExpirableAsync
,RObject
,RObjectAsync
,RQueue<V>
,RQueueAsync<V>
,RTransferQueue<V>
,RTransferQueueAsync<V>
public class RedissonTransferQueue<V> extends RedissonObject implements RTransferQueue<V>
- Author:
- Nikita Koksharov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RedissonTransferQueue.TransferQueueService
static interface
RedissonTransferQueue.TransferQueueServiceAsync
static class
RedissonTransferQueue.TransferQueueServiceImpl
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Constructor Description RedissonTransferQueue(Codec codec, CommandAsyncExecutor commandExecutor, String name, RRemoteService remoteService)
RedissonTransferQueue(CommandAsyncExecutor commandExecutor, String name, RRemoteService remoteService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(V v)
boolean
addAll(Collection<? extends V> c)
RFuture<Boolean>
addAllAsync(Collection<? extends V> c)
Adds all elements contained in the specified collectionRFuture<Boolean>
addAsync(V v)
Adds element into this collection.void
clear()
RFuture<Void>
clearAsync()
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.int
drainTo(Collection<? super V> c)
int
drainTo(Collection<? super V> c, int maxElements)
RFuture<Integer>
drainToAsync(Collection<? super V> c)
Removes all available elements from this queue and adds them to the given collection in async mode.RFuture<Integer>
drainToAsync(Collection<? super V> c, int maxElements)
Removes at most the given number of available elements from this queue and adds them to the given collection in async mode.V
element()
boolean
expire(long timeToLive, TimeUnit timeUnit)
UseRExpirable.expire(Duration)
insteadboolean
expire(Duration duration)
Sets a timeout for this object.boolean
expire(Instant instant)
Sets an expiration date for this object.RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit)
UseRExpirableAsync.expireAsync(Duration)
insteadprotected RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys)
RFuture<Boolean>
expireAsync(Duration duration)
Set a timeout for object.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 param, String... keys)
RFuture<Boolean>
expireAtAsync(Date timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadboolean
expireIfGreater(Duration duration)
Sets a timeout for this object only if it's greater than timeout set before.boolean
expireIfGreater(Instant time)
Sets an expiration date for this object only if it's greater than expiration date set before.RFuture<Boolean>
expireIfGreaterAsync(Duration duration)
RFuture<Boolean>
expireIfGreaterAsync(Instant time)
boolean
expireIfLess(Duration duration)
Sets a timeout for this object only if it's less than timeout set before.boolean
expireIfLess(Instant time)
Sets an expiration date for this object only if it's less than expiration date set before.RFuture<Boolean>
expireIfLessAsync(Duration duration)
RFuture<Boolean>
expireIfLessAsync(Instant time)
boolean
expireIfNotSet(Duration duration)
Sets a timeout for this object only if it hasn't been set before.boolean
expireIfNotSet(Instant time)
Sets an expiration date for this object only if it hasn't been set before.RFuture<Boolean>
expireIfNotSetAsync(Duration duration)
RFuture<Boolean>
expireIfNotSetAsync(Instant time)
boolean
expireIfSet(Duration duration)
Sets a timeout for this object only if it has been already set.boolean
expireIfSet(Instant time)
Sets an expiration date for this object only if it has been already set.RFuture<Boolean>
expireIfSetAsync(Duration duration)
RFuture<Boolean>
expireIfSetAsync(Instant time)
long
getExpireTime()
Expiration time of Redisson object that has a timeoutRFuture<Long>
getExpireTimeAsync()
Expiration time of Redisson object that has a timeoutRFuture<V>
getValueAsync(int index)
int
getWaitingConsumerCount()
boolean
hasWaitingConsumer()
boolean
isEmpty()
Iterator<V>
iterator()
boolean
offer(V v)
boolean
offer(V v, long timeout, TimeUnit unit)
RFuture<Boolean>
offerAsync(V e)
Inserts the specified element into this 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.V
poll(long timeout, TimeUnit unit)
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.RFuture<V>
pollAsync(long timeout, TimeUnit unit)
Retrieves and removes the head of this queue in async mode, waiting up to the specified wait time if necessary for an element to become available.Map<String,List<V>>
pollFirstFromAny(Duration duration, int count, String... queueNames)
Retrieves and removes first available head elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.RFuture<Map<String,List<V>>>
pollFirstFromAnyAsync(Duration duration, int count, String... queueNames)
Retrieves and removes first available head elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.V
pollFromAny(long timeout, TimeUnit unit, String... queueNames)
Retrieves and removes first available head element of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.RFuture<V>
pollFromAnyAsync(long timeout, TimeUnit unit, String... queueNames)
Retrieves and removes first available head element of any queue in async mode, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.V
pollLastAndOfferFirstTo(String queueName)
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.V
pollLastAndOfferFirstTo(String queueName, long timeout, TimeUnit unit)
Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.RFuture<V>
pollLastAndOfferFirstToAsync(String queueName)
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.RFuture<V>
pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit)
Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.Map<String,List<V>>
pollLastFromAny(Duration duration, int count, String... queueNames)
Retrieves and removes first available tail elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.RFuture<Map<String,List<V>>>
pollLastFromAnyAsync(Duration duration, int count, String... queueNames)
Retrieves and removes first available tail elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.void
put(V v)
RFuture<Void>
putAsync(V value)
Inserts the specified element into this queue in async mode, waiting if necessary for space to become available.List<V>
readAll()
Returns all queue elements at onceRFuture<List<V>>
readAllAsync()
Returns all queue elements at onceint
remainingCapacity()
long
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.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.int
subscribeOnElements(Consumer<V> consumer)
Subscribes on elements appeared in this queue.V
take()
RFuture<V>
takeAsync()
Retrieves and removes the head of this queue in async mode, waiting if necessary until an element becomes available.V
takeLastAndOfferFirstTo(String queueName)
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.RFuture<V>
takeLastAndOfferFirstToAsync(String queueName)
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.Object[]
toArray()
<T> T[]
toArray(T[] a)
void
transfer(V v)
RFuture<Void>
transferAsync(V v)
Transfers the element to waiting consumer which invokedRBlockingQueueAsync.takeAsync()
orRBlockingQueueAsync.pollAsync(long, java.util.concurrent.TimeUnit)
method at the moment of transfer.boolean
tryTransfer(V v)
boolean
tryTransfer(V v, long timeout, TimeUnit unit)
RFuture<Boolean>
tryTransferAsync(V v)
Tries to transfer the element to waiting consumer which invokedRBlockingQueueAsync.takeAsync()
orRBlockingQueueAsync.pollAsync(long, java.util.concurrent.TimeUnit)
method at the moment of transfer.RFuture<Boolean>
tryTransferAsync(V v, long timeout, TimeUnit unit)
Transfers the element to waiting consumer which invokedRBlockingQueueAsync.takeAsync()
orRBlockingQueueAsync.pollAsync(long, java.util.concurrent.TimeUnit)
method at the moment of transfer.void
unsubscribe(int listenerId)
Un-subscribes defined listener.-
Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, 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, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, 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, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, 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, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Methods inherited from interface org.redisson.api.RQueue
addListener
-
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync
-
-
-
-
Constructor Detail
-
RedissonTransferQueue
public RedissonTransferQueue(Codec codec, CommandAsyncExecutor commandExecutor, String name, RRemoteService remoteService)
-
RedissonTransferQueue
public RedissonTransferQueue(CommandAsyncExecutor commandExecutor, String name, RRemoteService remoteService)
-
-
Method Detail
-
tryTransfer
public boolean tryTransfer(V v)
- Specified by:
tryTransfer
in interfaceTransferQueue<V>
-
tryTransferAsync
public RFuture<Boolean> tryTransferAsync(V v)
Description copied from interface:RTransferQueueAsync
Tries to transfer the element to waiting consumer which invokedRBlockingQueueAsync.takeAsync()
orRBlockingQueueAsync.pollAsync(long, java.util.concurrent.TimeUnit)
method at the moment of transfer.- Specified by:
tryTransferAsync
in interfaceRTransferQueueAsync<V>
- Parameters:
v
- element to transfer- Returns:
true
if element was transferred, otherwisefalse
-
transfer
public void transfer(V v) throws InterruptedException
- Specified by:
transfer
in interfaceTransferQueue<V>
- Throws:
InterruptedException
-
transferAsync
public RFuture<Void> transferAsync(V v)
Description copied from interface:RTransferQueueAsync
Transfers the element to waiting consumer which invokedRBlockingQueueAsync.takeAsync()
orRBlockingQueueAsync.pollAsync(long, java.util.concurrent.TimeUnit)
method at the moment of transfer. Waits if necessary for a consumer.- Specified by:
transferAsync
in interfaceRTransferQueueAsync<V>
- Parameters:
v
- the element to transfer
-
tryTransfer
public boolean tryTransfer(V v, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
tryTransfer
in interfaceTransferQueue<V>
- Throws:
InterruptedException
-
tryTransferAsync
public RFuture<Boolean> tryTransferAsync(V v, long timeout, TimeUnit unit)
Description copied from interface:RTransferQueueAsync
Transfers the element to waiting consumer which invokedRBlockingQueueAsync.takeAsync()
orRBlockingQueueAsync.pollAsync(long, java.util.concurrent.TimeUnit)
method at the moment of transfer. Waits up to definedtimeout
if necessary for a consumer.- Specified by:
tryTransferAsync
in interfaceRTransferQueueAsync<V>
- Parameters:
v
- the element to transfertimeout
- the maximum time to waitunit
- the time unit- Returns:
true
if the element was transferred andfalse
otherwise
-
hasWaitingConsumer
public boolean hasWaitingConsumer()
- Specified by:
hasWaitingConsumer
in interfaceTransferQueue<V>
-
getWaitingConsumerCount
public int getWaitingConsumerCount()
- Specified by:
getWaitingConsumerCount
in interfaceTransferQueue<V>
-
add
public boolean add(V v)
- Specified by:
add
in interfaceBlockingQueue<V>
- Specified by:
add
in interfaceCollection<V>
- Specified by:
add
in interfaceQueue<V>
-
addAsync
public RFuture<Boolean> addAsync(V v)
Description copied from interface:RCollectionAsync
Adds element into this collection.- Specified by:
addAsync
in interfaceRCollectionAsync<V>
- Parameters:
v
- - element to add- Returns:
true
if an element was added andfalse
if it is already present
-
offer
public boolean offer(V v)
-
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
-
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
-
put
public void put(V v) throws InterruptedException
- Specified by:
put
in interfaceBlockingQueue<V>
- Throws:
InterruptedException
-
offer
public boolean offer(V v, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
offer
in interfaceBlockingQueue<V>
- Throws:
InterruptedException
-
take
public V take() throws InterruptedException
- Specified by:
take
in interfaceBlockingQueue<V>
- Throws:
InterruptedException
-
takeAsync
public RFuture<V> takeAsync()
Description copied from interface:RBlockingQueueAsync
Retrieves and removes the head of this queue in async mode, waiting if necessary until an element becomes available.- Specified by:
takeAsync
in interfaceRBlockingQueueAsync<V>
- Returns:
- the head of this queue
-
poll
public V poll(long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
poll
in interfaceBlockingQueue<V>
- Throws:
InterruptedException
-
pollAsync
public RFuture<V> pollAsync(long timeout, TimeUnit unit)
Description copied from interface:RBlockingQueueAsync
Retrieves and removes the head of this queue in async mode, waiting up to the specified wait time if necessary for an element to become available.- Specified by:
pollAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
timeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the head of this queue, or
null
if the specified waiting time elapses before an element is available
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in interfaceBlockingQueue<V>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceBlockingQueue<V>
- Specified by:
remove
in interfaceCollection<V>
-
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>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<V>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<V>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<V>
-
size
public int size()
- Specified by:
size
in interfaceCollection<V>
-
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
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<V>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceBlockingQueue<V>
- 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>
-
drainTo
public int drainTo(Collection<? super V> c)
- Specified by:
drainTo
in interfaceBlockingQueue<V>
-
drainToAsync
public RFuture<Integer> drainToAsync(Collection<? super V> c)
Description copied from interface:RBlockingQueueAsync
Removes all available elements from this queue and adds them to the given collection in async mode. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collectionc
may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result inIllegalArgumentException
. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.- Specified by:
drainToAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
c
- the collection to transfer elements into- Returns:
- the number of elements transferred
-
drainTo
public int drainTo(Collection<? super V> c, int maxElements)
- Specified by:
drainTo
in interfaceBlockingQueue<V>
-
drainToAsync
public RFuture<Integer> drainToAsync(Collection<? super V> c, int maxElements)
Description copied from interface:RBlockingQueueAsync
Removes at most the given number of available elements from this queue and adds them to the given collection in async mode. A failure encountered while attempting to add elements to collectionc
may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result inIllegalArgumentException
. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.- Specified by:
drainToAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
c
- the collection to transfer elements intomaxElements
- the maximum number of elements to transfer- Returns:
- the number of elements transferred
-
readAll
public List<V> readAll()
Description copied from interface:RTransferQueue
Returns all queue elements at once- Specified by:
readAll
in interfaceRQueue<V>
- Specified by:
readAll
in interfaceRTransferQueue<V>
- Specified by:
readAll
in interfaceRTransferQueueAsync<V>
- Returns:
- elements
-
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
-
pollFromAny
public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException
Description copied from interface:RBlockingQueue
Retrieves and removes first available head element of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.- Specified by:
pollFromAny
in interfaceRBlockingQueue<V>
- Parameters:
timeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameterqueueNames
- - queue names. Queue name itself is always included- Returns:
- the head of this queue, or
null
if the specified waiting time elapses before an element is available - Throws:
InterruptedException
- if interrupted while waiting
-
pollFirstFromAny
public Map<String,List<V>> pollFirstFromAny(Duration duration, int count, String... queueNames) throws InterruptedException
Description copied from interface:RBlockingQueue
Retrieves and removes first available head elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.Requires Redis 7.0.0 and higher.
- Specified by:
pollFirstFromAny
in interfaceRBlockingQueue<V>
- Parameters:
duration
- how long to wait before giving upcount
- elements amountqueueNames
- name of queues- Returns:
- the head elements
- Throws:
InterruptedException
-
pollLastFromAny
public Map<String,List<V>> pollLastFromAny(Duration duration, int count, String... queueNames) throws InterruptedException
Description copied from interface:RBlockingQueue
Retrieves and removes first available tail elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.Requires Redis 7.0.0 and higher.
- Specified by:
pollLastFromAny
in interfaceRBlockingQueue<V>
- Parameters:
duration
- how long to wait before giving upcount
- elements amountqueueNames
- name of queues- Returns:
- the tail elements
- Throws:
InterruptedException
-
pollFirstFromAnyAsync
public RFuture<Map<String,List<V>>> pollFirstFromAnyAsync(Duration duration, int count, String... queueNames)
Description copied from interface:RBlockingQueueAsync
Retrieves and removes first available head elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.Requires Redis 7.0.0 and higher.
- Specified by:
pollFirstFromAnyAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
duration
- how long to wait before giving upcount
- elements amountqueueNames
- name of queues- Returns:
- the head elements
-
pollLastFromAnyAsync
public RFuture<Map<String,List<V>>> pollLastFromAnyAsync(Duration duration, int count, String... queueNames)
Description copied from interface:RBlockingQueueAsync
Retrieves and removes first available tail elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.Requires Redis 7.0.0 and higher.
- Specified by:
pollLastFromAnyAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
duration
- how long to wait before giving upcount
- elements amountqueueNames
- name of queues- Returns:
- the tail elements
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String queueName, long timeout, TimeUnit unit) throws InterruptedException
Description copied from interface:RBlockingQueue
Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.- Specified by:
pollLastAndOfferFirstTo
in interfaceRBlockingQueue<V>
- Parameters:
queueName
- - names of destination queuetimeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available - Throws:
InterruptedException
- if interrupted while waiting
-
takeLastAndOfferFirstTo
public V takeLastAndOfferFirstTo(String queueName) throws InterruptedException
Description copied from interface:RBlockingQueue
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.- Specified by:
takeLastAndOfferFirstTo
in interfaceRBlockingQueue<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 - Throws:
InterruptedException
- if interrupted while waiting
-
subscribeOnElements
public int subscribeOnElements(Consumer<V> consumer)
Description copied from interface:RBlockingQueue
Subscribes on elements appeared in this queue. Continuously invokesRBlockingQueueAsync.takeAsync()
method to get a new element.- Specified by:
subscribeOnElements
in interfaceRBlockingQueue<V>
- Parameters:
consumer
- - queue elements listener- Returns:
- listenerId - id of listener
-
unsubscribe
public void unsubscribe(int listenerId)
Description copied from interface:RBlockingQueue
Un-subscribes defined listener.- Specified by:
unsubscribe
in interfaceRBlockingQueue<V>
- Parameters:
listenerId
- - id of listener
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String queueName)
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:
queueName
- - names of destination queue- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available
-
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.
-
pollFromAnyAsync
public RFuture<V> pollFromAnyAsync(long timeout, TimeUnit unit, String... queueNames)
Description copied from interface:RBlockingQueueAsync
Retrieves and removes first available head element of any queue in async mode, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.- Specified by:
pollFromAnyAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
timeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameterqueueNames
- - queue names. Queue name itself is always included- Returns:
- Future object with the head of this queue, or
null
if the specified waiting time elapses before an element is available
-
pollLastAndOfferFirstToAsync
public RFuture<V> pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit)
Description copied from interface:RBlockingQueueAsync
Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.- Specified by:
pollLastAndOfferFirstToAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
queueName
- - names of destination queuetimeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available
-
takeLastAndOfferFirstToAsync
public RFuture<V> takeLastAndOfferFirstToAsync(String queueName)
Description copied from interface:RBlockingQueueAsync
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.- Specified by:
takeLastAndOfferFirstToAsync
in interfaceRBlockingQueueAsync<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
-
putAsync
public RFuture<Void> putAsync(V value)
Description copied from interface:RBlockingQueueAsync
Inserts the specified element into this queue in async mode, waiting if necessary for space to become available.- Specified by:
putAsync
in interfaceRBlockingQueueAsync<V>
- Parameters:
value
- the element to add- Returns:
- void
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirable
UseRExpirable.expire(Duration)
instead- 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
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Duration)
instead- 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
-
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
Sets an expiration date for this 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
-
expireIfSet
public boolean expireIfSet(Instant time)
Description copied from interface:RExpirable
Sets an expiration date for this object only if it has been already set. When expire date comes the object will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfSet
in interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfSetAsync
public RFuture<Boolean> expireIfSetAsync(Instant time)
- Specified by:
expireIfSetAsync
in interfaceRExpirableAsync
-
expireIfNotSet
public boolean expireIfNotSet(Instant time)
Description copied from interface:RExpirable
Sets an expiration date for this object only if it hasn't been set before. When expire date comes the object will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfNotSet
in interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfNotSetAsync
public RFuture<Boolean> expireIfNotSetAsync(Instant time)
- Specified by:
expireIfNotSetAsync
in interfaceRExpirableAsync
-
expireIfGreater
public boolean expireIfGreater(Instant time)
Description copied from interface:RExpirable
Sets an expiration date for this object only if it's greater than expiration date set before. When expire date comes the object will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfGreater
in interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfGreaterAsync
public RFuture<Boolean> expireIfGreaterAsync(Instant time)
- Specified by:
expireIfGreaterAsync
in interfaceRExpirableAsync
-
expireIfLess
public boolean expireIfLess(Instant time)
Description copied from interface:RExpirable
Sets an expiration date for this object only if it's less than expiration date set before. When expire date comes the object will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfLess
in interfaceRExpirable
- Parameters:
time
- expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireIfLessAsync
public RFuture<Boolean> expireIfLessAsync(Instant time)
- Specified by:
expireIfLessAsync
in interfaceRExpirableAsync
-
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
-
expire
public boolean expire(Duration duration)
Description copied from interface:RExpirable
Sets a timeout for this object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(Duration duration)
Description copied from interface:RExpirableAsync
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
duration
- timeout before object will be deleted- 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
-
expireIfSet
public boolean expireIfSet(Duration duration)
Description copied from interface:RExpirable
Sets a timeout for this object only if it has been already set. After the timeout has expired, the key will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfSet
in interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfSetAsync
public RFuture<Boolean> expireIfSetAsync(Duration duration)
- Specified by:
expireIfSetAsync
in interfaceRExpirableAsync
-
expireIfNotSet
public boolean expireIfNotSet(Duration duration)
Description copied from interface:RExpirable
Sets a timeout for this object only if it hasn't been set before. After the timeout has expired, the key will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfNotSet
in interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfNotSetAsync
public RFuture<Boolean> expireIfNotSetAsync(Duration duration)
- Specified by:
expireIfNotSetAsync
in interfaceRExpirableAsync
-
expireIfGreater
public boolean expireIfGreater(Duration duration)
Description copied from interface:RExpirable
Sets a timeout for this object only if it's greater than timeout set before. After the timeout has expired, the key will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfGreater
in interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfGreaterAsync
public RFuture<Boolean> expireIfGreaterAsync(Duration duration)
- Specified by:
expireIfGreaterAsync
in interfaceRExpirableAsync
-
expireIfLess
public boolean expireIfLess(Duration duration)
Description copied from interface:RExpirable
Sets a timeout for this object only if it's less than timeout set before. After the timeout has expired, the key will automatically be deleted.Requires Redis 7.0.0 and higher.
- Specified by:
expireIfLess
in interfaceRExpirable
- Parameters:
duration
- timeout before object will be deleted- Returns:
true
if the timeout was set andfalse
if not
-
expireIfLessAsync
public RFuture<Boolean> expireIfLessAsync(Duration duration)
- Specified by:
expireIfLessAsync
in interfaceRExpirableAsync
-
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
-
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
-
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.
-
getExpireTime
public long getExpireTime()
Description copied from interface:RExpirable
Expiration time of Redisson object that has a timeoutRequires Redis 7.0.0 and higher.
- Specified by:
getExpireTime
in interfaceRExpirable
- Returns:
- expiration time
-
getExpireTimeAsync
public RFuture<Long> getExpireTimeAsync()
Description copied from interface:RExpirableAsync
Expiration time of Redisson object that has a timeoutRequires Redis 7.0.0 and higher.
- Specified by:
getExpireTimeAsync
in interfaceRExpirableAsync
- Returns:
- expiration time
-
expireAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys)
-
expireAtAsync
protected RFuture<Boolean> expireAtAsync(long timestamp, String param, String... keys)
-
-