Package org.redisson
Class RedissonQueue<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonList<V>
-
- org.redisson.RedissonQueue<V>
-
- Type Parameters:
V- the type of elements held in this collection
- All Implemented Interfaces:
Iterable<V>,Collection<V>,List<V>,Queue<V>,RandomAccess,RCollectionAsync<V>,RExpirable,RExpirableAsync,RList<V>,RListAsync<V>,RObject,RObjectAsync,RQueue<V>,RQueueAsync<V>,RSortable<List<V>>,RSortableAsync<List<V>>
- Direct Known Subclasses:
RedissonBlockingQueue,RedissonBoundedBlockingQueue,RedissonDeque,RedissonRingBuffer
public class RedissonQueue<V> extends RedissonList<V> implements RQueue<V>
Distributed and concurrent implementation ofQueue- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Constructor Description RedissonQueue(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)RedissonQueue(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)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)insteadVgetFirst()booleanoffer(V e)RFuture<Boolean>offerAsync(V e)Inserts the specified element into this 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 queueName)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.longremainTimeToLive()Remaining time to live of Redisson object that has a timeoutRFuture<Long>remainTimeToLiveAsync()Remaining time to live of Redisson object that has a timeoutVremove()VremoveFirst()-
Methods inherited from class org.redisson.RedissonList
add, add, addAfter, addAfterAsync, addAll, addAll, addAllAsync, addAllAsync, addAsync, addAsync, addAsync, addBefore, addBeforeAsync, addListener, addListenerAsync, clear, contains, containsAll, containsAllAsync, containsAsync, equals, fastRemove, fastRemoveAsync, fastSet, fastSetAsync, get, get, getAsync, getAsync, hashCode, indexOf, indexOfAsync, indexOfAsync, isEmpty, iterator, lastIndexOf, lastIndexOfAsync, lastIndexOfAsync, listIterator, listIterator, mapReduce, range, range, rangeAsync, rangeAsync, readAll, readAllAsync, readSort, readSort, readSort, readSort, readSort, readSort, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, remove, remove, remove, removeAll, removeAllAsync, removeAsync, removeAsync, removeAsync, removeIf, removeListener, removeListenerAsync, retainAll, retainAllAsync, set, setAsync, size, sizeAsync, sortTo, sortTo, sortTo, sortTo, sortTo, sortTo, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, subList, toArray, toArray, toString, trim, trimAsync
-
Methods inherited from class org.redisson.RedissonObject
addListener, 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, removeListenersAsync, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Methods inherited from interface org.redisson.api.RCollectionAsync
addAllAsync, addAsync, containsAllAsync, containsAsync, removeAllAsync, removeAsync, retainAllAsync, sizeAsync
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObject
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, readAll
-
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync, readAllAsync
-
-
-
-
Constructor Detail
-
RedissonQueue
public RedissonQueue(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
RedissonQueue
public RedissonQueue(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
-
Method Detail
-
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
-
getFirst
public V getFirst()
-
removeFirst
public V removeFirst()
-
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
-
poll
public List<V> poll(int limit)
Description copied from interface:RQueueRetrieves and removes the head elements of this queue. Elements amount limited bylimitparam.
-
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
-
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
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String queueName)
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:
queueName- - names of destination queue- Returns:
- the tail of this queue, or
nullif the specified waiting time elapses before an element is available
-
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
-
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
-
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
-
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
-
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
-
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)
-
-