Package org.redisson

Class 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
  • Constructor Details

  • Method Details

    • offer

      public boolean offer(V e)
      Specified by:
      offer in interface Queue<V>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<V>
      Specified by:
      contains in interface List<V>
      Overrides:
      contains in class RedissonList<V>
    • add

      public boolean add(V value)
      Specified by:
      add in interface Collection<V>
      Specified by:
      add in interface List<V>
      Specified by:
      add in interface Queue<V>
      Overrides:
      add in class RedissonList<V>
    • remove

      public boolean remove(Object value)
      Specified by:
      remove in interface Collection<V>
      Specified by:
      remove in interface List<V>
      Overrides:
      remove in class RedissonList<V>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<V>
      Specified by:
      containsAll in interface List<V>
      Overrides:
      containsAll in class RedissonList<V>
    • addAll

      public boolean addAll(Collection<? extends V> c)
      Specified by:
      addAll in interface Collection<V>
      Specified by:
      addAll in interface List<V>
      Overrides:
      addAll in class RedissonList<V>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<V>
      Specified by:
      retainAll in interface List<V>
      Overrides:
      retainAll in class RedissonList<V>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<V>
      Specified by:
      removeAll in interface List<V>
      Overrides:
      removeAll in class RedissonList<V>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<V>
      Specified by:
      clear in interface List<V>
      Overrides:
      clear in class RedissonList<V>
    • comparator

      public Comparator<? super V> comparator()
      Description copied from interface: RPriorityQueue
      Returns comparator used by this queue
      Specified by:
      comparator in interface RPriorityQueue<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 interface RQueueAsync<V>
      Returns:
      the head of this queue, or null
    • wrapLockedAsync

      protected <T> RFuture<V> wrapLockedAsync(RedisCommand<T> command, Object... params)
    • wrapLockedAsync

      protected final <T, R> RFuture<R> wrapLockedAsync(Supplier<RFuture<R>> callable)
    • getFirst

      public V getFirst()
    • poll

      public V poll()
      Specified by:
      poll in interface Queue<V>
    • element

      public V element()
      Specified by:
      element in interface Queue<V>
    • peekAsync

      public RFuture<V> peekAsync()
      Description copied from interface: RQueueAsync
      Retrieves the head of this queue in async mode.
      Specified by:
      peekAsync in interface RQueueAsync<V>
      Returns:
      the head of this queue, or null
    • peek

      public V peek()
      Specified by:
      peek in interface Queue<V>
    • 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 interface RPriorityQueue<V>
      Parameters:
      comparator - for values
      Returns:
      true if new comparator setted false otherwise
    • remove

      public V remove()
      Specified by:
      remove in interface Queue<V>
    • removeFirst

      public V removeFirst()
    • binarySearch

      public RedissonPriorityQueue.BinarySearchResult<V> binarySearch(V value)
    • toString

      public String toString()
      Overrides:
      toString in class RedissonList<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 of queueName.
      Specified by:
      pollLastAndOfferFirstTo in interface RPriorityQueue<V>
      Specified by:
      pollLastAndOfferFirstTo in interface RQueue<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 of queueName.
      Specified by:
      pollLastAndOfferFirstToAsync in interface RQueueAsync<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 interface RObjectAsync
      Overrides:
      deleteAsync in class RedissonObject
      Returns:
      true if object was deleted false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys)
    • expireAtAsync

      protected RFuture<Boolean> expireAtAsync(long timestamp, String param, String... keys)
    • 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 interface RExpirableAsync
      Returns:
      true if the timeout was cleared and false 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 by limit param.
      Specified by:
      poll in interface RQueue<V>
      Returns:
      list of head elements
    • offerAsync

      public RFuture<Boolean> offerAsync(V e)
      Description copied from interface: RQueueAsync
      Inserts the specified element into this queue.
      Specified by:
      offerAsync in interface RQueueAsync<V>
      Parameters:
      e - the element to add
      Returns:
      true if successful, or false
    • addAsync

      public RFuture<Boolean> addAsync(V e)
      Description copied from interface: RCollectionAsync
      Adds element into this collection.
      Specified by:
      addAsync in interface RCollectionAsync<V>
      Overrides:
      addAsync in class RedissonList<V>
      Parameters:
      e - - element to add
      Returns:
      true if an element was added and false 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 by limit param.
      Specified by:
      pollAsync in interface RQueueAsync<V>
      Returns:
      list of head elements
    • expire

      public boolean expire(long timeToLive, TimeUnit timeUnit)
      Description copied from interface: RExpirable
      Specified by:
      expire in interface RExpirable
      Parameters:
      timeToLive - - timeout before object will be deleted
      timeUnit - - timeout time unit
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      timeToLive - - timeout before object will be deleted
      timeUnit - - timeout time unit
      Returns:
      true if the timeout was set and false if not
    • expireAt

      public boolean expireAt(long timestamp)
      Description copied from interface: RExpirable
      Specified by:
      expireAt in interface RExpirable
      Parameters:
      timestamp - - expire date in milliseconds (Unix timestamp)
      Returns:
      true if the timeout was set and false if not
    • expireAtAsync

      public RFuture<Boolean> expireAtAsync(long timestamp)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAtAsync in interface RExpirableAsync
      Parameters:
      timestamp - - expire date in milliseconds (Unix timestamp)
      Returns:
      true if the timeout was set and false 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 interface RExpirable
      Parameters:
      instant - expire date
      Returns:
      true if the timeout was set and false 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 interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSetAsync

      public RFuture<Boolean> expireIfSetAsync(Instant time)
      Description copied from interface: RExpirableAsync
      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:
      expireIfSetAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • 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 interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSetAsync

      public RFuture<Boolean> expireIfNotSetAsync(Instant time)
      Description copied from interface: RExpirableAsync
      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:
      expireIfNotSetAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • 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 interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfGreaterAsync

      public RFuture<Boolean> expireIfGreaterAsync(Instant time)
      Description copied from interface: RExpirableAsync
      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:
      expireIfGreaterAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • 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 interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfLessAsync

      public RFuture<Boolean> expireIfLessAsync(Instant time)
      Description copied from interface: RExpirableAsync
      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:
      expireIfLessAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false 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 interface RExpirableAsync
      Parameters:
      instant - - expire date
      Returns:
      true if the timeout was set and false 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 interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false 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 interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireAt

      public boolean expireAt(Date timestamp)
      Description copied from interface: RExpirable
      Specified by:
      expireAt in interface RExpirable
      Parameters:
      timestamp - - expire date
      Returns:
      true if the timeout was set and false if not
    • expireAtAsync

      public RFuture<Boolean> expireAtAsync(Date timestamp)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAtAsync in interface RExpirableAsync
      Parameters:
      timestamp - - expire date
      Returns:
      true if the timeout was set and false 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 interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfSetAsync

      public RFuture<Boolean> expireIfSetAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      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:
      expireIfSetAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • 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 interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSetAsync

      public RFuture<Boolean> expireIfNotSetAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      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:
      expireIfNotSetAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • 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 interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfGreaterAsync

      public RFuture<Boolean> expireIfGreaterAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      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:
      expireIfGreaterAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • 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 interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfLessAsync

      public RFuture<Boolean> expireIfLessAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      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:
      expireIfLessAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • clearExpire

      public boolean clearExpire()
      Description copied from interface: RExpirable
      Clear an expire timeout or expire date for object.
      Specified by:
      clearExpire in interface RExpirable
      Returns:
      true if timeout was removed false 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 interface RExpirable
      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 interface RExpirableAsync
      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 timeout

      Requires Redis 7.0.0 and higher.

      Specified by:
      getExpireTime in interface RExpirable
      Returns:
      expiration time
    • getExpireTimeAsync

      public RFuture<Long> getExpireTimeAsync()
      Description copied from interface: RExpirableAsync
      Expiration time of Redisson object that has a timeout

      Requires Redis 7.0.0 and higher.

      Specified by:
      getExpireTimeAsync in interface RExpirableAsync
      Returns:
      expiration time
    • clearExpireAsync

      protected RFuture<Boolean> clearExpireAsync(String... keys)