Package org.redisson
Class RedissonPriorityQueue<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonList<V>
-
- org.redisson.RedissonPriorityQueue<V>
-
- Type Parameters:
V
- value type
- All Implemented Interfaces:
Iterable<V>
,Collection<V>
,List<V>
,Queue<V>
,RandomAccess
,RCollectionAsync<V>
,RExpirable
,RExpirableAsync
,RList<V>
,RListAsync<V>
,RObject
,RObjectAsync
,RPriorityQueue<V>
,RQueue<V>
,RQueueAsync<V>
,RSortable<List<V>>
,RSortableAsync<List<V>>
- Direct Known Subclasses:
RedissonPriorityBlockingQueue
,RedissonPriorityDeque
public class RedissonPriorityQueue<V> extends RedissonList<V> implements RPriorityQueue<V>
- Author:
- Nikita Koksharov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RedissonPriorityQueue.BinarySearchResult<V>
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, name
-
-
Constructor Summary
Constructors Constructor Description RedissonPriorityQueue(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
RedissonPriorityQueue(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(V value)
boolean
addAll(Collection<? extends V> c)
RFuture<Boolean>
addAsync(V e)
Adds element into this collection.RedissonPriorityQueue.BinarySearchResult<V>
binarySearch(V value)
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)
Comparator<? super V>
comparator()
Returns comparator used by this queueboolean
contains(Object o)
boolean
containsAll(Collection<?> c)
RFuture<Boolean>
deleteAsync()
Delete object in async modeV
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)
insteadV
getFirst()
boolean
offer(V e)
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.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 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
.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 value)
boolean
removeAll(Collection<?> c)
V
removeFirst()
boolean
retainAll(Collection<?> c)
String
toString()
boolean
trySetComparator(Comparator<? super V> comparator)
Sets new comparator only if current set is emptyprotected <T,R>
RFuture<R>wrapLockedAsync(Supplier<RFuture<R>> callable)
protected <T> RFuture<V>
wrapLockedAsync(RedisCommand<T> command, Object... params)
-
Methods inherited from class org.redisson.RedissonList
add, addAfter, addAfterAsync, addAll, addAllAsync, addAllAsync, addAsync, addAsync, addBefore, addBeforeAsync, addListener, addListenerAsync, 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, removeAllAsync, removeAsync, removeAsync, removeAsync, removeIf, removeListener, removeListenerAsync, retainAllAsync, set, setAsync, size, sizeAsync, sortTo, sortTo, sortTo, sortTo, sortTo, sortTo, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, subList, toArray, toArray, trim, trimAsync
-
Methods inherited from class org.redisson.RedissonObject
addListener, 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, 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, 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
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, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Methods inherited from interface org.redisson.api.RPriorityQueue
readAll
-
Methods inherited from interface org.redisson.api.RQueue
addListener
-
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync, readAllAsync
-
-
-
-
Constructor Detail
-
RedissonPriorityQueue
public RedissonPriorityQueue(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
RedissonPriorityQueue
public RedissonPriorityQueue(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
-
Method Detail
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<V>
- Specified by:
contains
in interfaceList<V>
- Overrides:
contains
in classRedissonList<V>
-
add
public boolean add(V value)
-
remove
public boolean remove(Object value)
- Specified by:
remove
in interfaceCollection<V>
- Specified by:
remove
in interfaceList<V>
- Overrides:
remove
in classRedissonList<V>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<V>
- Specified by:
containsAll
in interfaceList<V>
- Overrides:
containsAll
in classRedissonList<V>
-
addAll
public boolean addAll(Collection<? extends V> c)
- Specified by:
addAll
in interfaceCollection<V>
- Specified by:
addAll
in interfaceList<V>
- Overrides:
addAll
in classRedissonList<V>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<V>
- Specified by:
retainAll
in interfaceList<V>
- Overrides:
retainAll
in classRedissonList<V>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<V>
- Specified by:
removeAll
in interfaceList<V>
- Overrides:
removeAll
in classRedissonList<V>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<V>
- Specified by:
clear
in interfaceList<V>
- Overrides:
clear
in classRedissonList<V>
-
comparator
public Comparator<? super V> comparator()
Description copied from interface:RPriorityQueue
Returns comparator used by this queue- Specified by:
comparator
in interfaceRPriorityQueue<V>
- Returns:
- comparator object
-
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
-
wrapLockedAsync
protected <T> RFuture<V> wrapLockedAsync(RedisCommand<T> command, Object... params)
-
getFirst
public V getFirst()
-
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
-
trySetComparator
public boolean trySetComparator(Comparator<? super V> comparator)
Description copied from interface:RPriorityQueue
Sets new comparator only if current set is empty- Specified by:
trySetComparator
in interfaceRPriorityQueue<V>
- Parameters:
comparator
- for values- Returns:
true
if new comparator settedfalse
otherwise
-
removeFirst
public V removeFirst()
-
binarySearch
public RedissonPriorityQueue.BinarySearchResult<V> binarySearch(V value)
-
toString
public String toString()
- Overrides:
toString
in classRedissonList<V>
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String queueName)
Description copied from interface:RPriorityQueue
Retrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName
.- Specified by:
pollLastAndOfferFirstTo
in interfaceRPriorityQueue<V>
- 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
-
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
-
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
-
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
-
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.
-
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
-
addAsync
public RFuture<Boolean> addAsync(V e)
Description copied from interface:RCollectionAsync
Adds element into this collection.- Specified by:
addAsync
in interfaceRCollectionAsync<V>
- Overrides:
addAsync
in classRedissonList<V>
- Parameters:
e
- - element to add- Returns:
true
if an element was added andfalse
if it is already present
-
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
-
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)
-
-