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 classRedissonPriorityQueue.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 booleanadd(V value)booleanaddAll(Collection<? extends V> c)RFuture<Boolean>addAsync(V e)Adds element into this collection.RedissonPriorityQueue.BinarySearchResult<V>binarySearch(V value)voidclear()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)Comparator<? super V>comparator()Returns comparator used by this queuebooleancontains(Object o)booleancontainsAll(Collection<?> c)RFuture<Boolean>deleteAsync()Delete object in async modeVelement()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()booleanremove(Object value)booleanremoveAll(Collection<?> c)VremoveFirst()booleanretainAll(Collection<?> c)StringtoString()booleantrySetComparator(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:
containsin interfaceCollection<V>- Specified by:
containsin interfaceList<V>- Overrides:
containsin classRedissonList<V>
-
add
public boolean add(V value)
-
remove
public boolean remove(Object value)
- Specified by:
removein interfaceCollection<V>- Specified by:
removein interfaceList<V>- Overrides:
removein classRedissonList<V>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<V>- Specified by:
containsAllin interfaceList<V>- Overrides:
containsAllin classRedissonList<V>
-
addAll
public boolean addAll(Collection<? extends V> c)
- Specified by:
addAllin interfaceCollection<V>- Specified by:
addAllin interfaceList<V>- Overrides:
addAllin classRedissonList<V>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<V>- Specified by:
retainAllin interfaceList<V>- Overrides:
retainAllin classRedissonList<V>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<V>- Specified by:
removeAllin interfaceList<V>- Overrides:
removeAllin classRedissonList<V>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<V>- Specified by:
clearin interfaceList<V>- Overrides:
clearin classRedissonList<V>
-
comparator
public Comparator<? super V> comparator()
Description copied from interface:RPriorityQueueReturns comparator used by this queue- Specified by:
comparatorin interfaceRPriorityQueue<V>- Returns:
- comparator object
-
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
-
wrapLockedAsync
protected <T> RFuture<V> wrapLockedAsync(RedisCommand<T> command, Object... params)
-
getFirst
public V getFirst()
-
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
-
trySetComparator
public boolean trySetComparator(Comparator<? super V> comparator)
Description copied from interface:RPriorityQueueSets new comparator only if current set is empty- Specified by:
trySetComparatorin interfaceRPriorityQueue<V>- Parameters:
comparator- for values- Returns:
trueif new comparator settedfalseotherwise
-
removeFirst
public V removeFirst()
-
binarySearch
public RedissonPriorityQueue.BinarySearchResult<V> binarySearch(V value)
-
toString
public String toString()
- Overrides:
toStringin classRedissonList<V>
-
pollLastAndOfferFirstTo
public V pollLastAndOfferFirstTo(String queueName)
Description copied from interface:RPriorityQueueRetrieves and removes last available tail element of this queue queue and adds it at the head ofqueueName.- Specified by:
pollLastAndOfferFirstToin interfaceRPriorityQueue<V>- 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
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif 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
-
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
-
poll
public List<V> poll(int limit)
Description copied from interface:RQueueRetrieves and removes the head elements of this queue. Elements amount limited bylimitparam.
-
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
-
addAsync
public RFuture<Boolean> addAsync(V e)
Description copied from interface:RCollectionAsyncAdds element into this collection.- Specified by:
addAsyncin interfaceRCollectionAsync<V>- Overrides:
addAsyncin classRedissonList<V>- Parameters:
e- - element to add- Returns:
trueif an element was added andfalseif it is already present
-
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
-
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
-
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
-
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)
-
-