Package org.redisson

Class RedissonPriorityDeque<V>

Type Parameters:
V - the type of elements held in this collection
All Implemented Interfaces:
Iterable<V>, Collection<V>, Deque<V>, List<V>, Queue<V>, RandomAccess, RCollectionAsync<V>, RDeque<V>, RDequeAsync<V>, RExpirable, RExpirableAsync, RList<V>, RListAsync<V>, RObject, RObjectAsync, RPriorityDeque<V>, RPriorityQueue<V>, RQueue<V>, RQueueAsync<V>, RSortable<List<V>>, RSortableAsync<List<V>>
Direct Known Subclasses:
RedissonPriorityBlockingDeque

public class RedissonPriorityDeque<V> extends RedissonPriorityQueue<V> implements RPriorityDeque<V>
Distributed and concurrent implementation of Queue
Author:
Nikita Koksharov
  • Constructor Details

  • Method Details

    • addFirstIfExists

      public int addFirstIfExists(V... elements)
      Description copied from interface: RDeque
      Adds element at the head of existing deque.
      Specified by:
      addFirstIfExists in interface RDeque<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the list
    • addLastIfExists

      public int addLastIfExists(V... elements)
      Description copied from interface: RDeque
      Adds element at the tail of existing deque.
      Specified by:
      addLastIfExists in interface RDeque<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the list
    • addFirst

      public int addFirst(V... elements)
      Description copied from interface: RDeque
      Adds elements at the head of deque.
      Specified by:
      addFirst in interface RDeque<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the deque
    • addLast

      public int addLast(V... elements)
      Description copied from interface: RDeque
      Adds elements at the tail of deque.
      Specified by:
      addLast in interface RDeque<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the deque
    • addFirstAsync

      public RFuture<Integer> addFirstAsync(V... elements)
      Description copied from interface: RDequeAsync
      Adds elements at the head of deque.
      Specified by:
      addFirstAsync in interface RDequeAsync<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the deque
    • addLastAsync

      public RFuture<Integer> addLastAsync(V... elements)
      Description copied from interface: RDequeAsync
      Adds elements at the tail of deque.
      Specified by:
      addLastAsync in interface RDequeAsync<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the deque
    • addFirstIfExistsAsync

      public RFuture<Integer> addFirstIfExistsAsync(V... elements)
      Description copied from interface: RDequeAsync
      Adds element at the head of existing deque.
      Specified by:
      addFirstIfExistsAsync in interface RDequeAsync<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the list
    • addLastIfExistsAsync

      public RFuture<Integer> addLastIfExistsAsync(V... elements)
      Description copied from interface: RDequeAsync
      Adds element at the tail of existing deque.
      Specified by:
      addLastIfExistsAsync in interface RDequeAsync<V>
      Parameters:
      elements - - elements to add
      Returns:
      length of the list
    • addFirstAsync

      public RFuture<Void> addFirstAsync(V e)
      Description copied from interface: RDequeAsync
      Adds element at the head of this deque.
      Specified by:
      addFirstAsync in interface RDequeAsync<V>
      Parameters:
      e - - element to add
      Returns:
      void
    • addLastAsync

      public RFuture<Void> addLastAsync(V e)
      Description copied from interface: RDequeAsync
      Adds element at the tail of this deque.
      Specified by:
      addLastAsync in interface RDequeAsync<V>
      Parameters:
      e - - element to add
      Returns:
      void
    • addFirst

      public void addFirst(V e)
      Specified by:
      addFirst in interface Deque<V>
    • addLast

      public void addLast(V e)
      Specified by:
      addLast in interface Deque<V>
    • descendingIterator

      public Iterator<V> descendingIterator()
      Specified by:
      descendingIterator in interface Deque<V>
    • getLastAsync

      public RFuture<V> getLastAsync()
      Description copied from interface: RDequeAsync
      Returns element at the tail of this deque or null if there are no elements in deque.
      Specified by:
      getLastAsync in interface RDequeAsync<V>
      Returns:
      element
    • getLast

      public V getLast()
      Specified by:
      getLast in interface Deque<V>
    • offerFirst

      public boolean offerFirst(V e)
      Specified by:
      offerFirst in interface Deque<V>
    • offerFirstAsync

      public RFuture<Boolean> offerFirstAsync(V e)
      Description copied from interface: RDequeAsync
      Adds element at the head of this deque.
      Specified by:
      offerFirstAsync in interface RDequeAsync<V>
      Parameters:
      e - - element to add
      Returns:
      true if element was added to this deque otherwise false
    • offerLast

      public boolean offerLast(V e)
      Specified by:
      offerLast in interface Deque<V>
    • offerLastAsync

      public RFuture<Boolean> offerLastAsync(V e)
      Description copied from interface: RDequeAsync
      Adds element at the tail of this deque.
      Specified by:
      offerLastAsync in interface RDequeAsync<V>
      Parameters:
      e - - element to add
      Returns:
      true if element was added to this deque otherwise false
    • peekFirstAsync

      public RFuture<V> peekFirstAsync()
      Description copied from interface: RDequeAsync
      Returns element at the head of this deque or null if there are no elements in deque.
      Specified by:
      peekFirstAsync in interface RDequeAsync<V>
      Returns:
      element
    • peekFirst

      public V peekFirst()
      Specified by:
      peekFirst in interface Deque<V>
    • peekLast

      public V peekLast()
      Specified by:
      peekLast in interface Deque<V>
    • peekLastAsync

      public RFuture<V> peekLastAsync()
      Description copied from interface: RDequeAsync
      Returns element at the tail of this deque or null if there are no elements in deque.
      Specified by:
      peekLastAsync in interface RDequeAsync<V>
      Returns:
      element
    • pollFirst

      public V pollFirst()
      Specified by:
      pollFirst in interface Deque<V>
    • pollFirstAsync

      public RFuture<V> pollFirstAsync()
      Description copied from interface: RDequeAsync
      Retrieves and removes element at the head of this deque. Returns null if there are no elements in deque.
      Specified by:
      pollFirstAsync in interface RDequeAsync<V>
      Returns:
      element
    • pollLastAsync

      public RFuture<V> pollLastAsync()
      Description copied from interface: RDequeAsync
      Retrieves and removes element at the tail of this deque. Returns null if there are no elements in deque.
      Specified by:
      pollLastAsync in interface RDequeAsync<V>
      Returns:
      element
    • pollLast

      public V pollLast()
      Specified by:
      pollLast in interface Deque<V>
    • popAsync

      public RFuture<V> popAsync()
      Description copied from interface: RDequeAsync
      Retrieves and removes element at the head of this deque. Returns null if there are no elements in deque.
      Specified by:
      popAsync in interface RDequeAsync<V>
      Returns:
      element
    • pop

      public V pop()
      Specified by:
      pop in interface Deque<V>
    • push

      public void push(V e)
      Specified by:
      push in interface Deque<V>
    • pushAsync

      public RFuture<Void> pushAsync(V e)
      Description copied from interface: RDequeAsync
      Adds element at the head of this deque.
      Specified by:
      pushAsync in interface RDequeAsync<V>
      Parameters:
      e - - element to add
      Returns:
      void
    • removeAsync

      public RFuture<Boolean> removeAsync(Object o, int count)
      Description copied from interface: RListAsync
      Removes up to count occurrences of element
      Specified by:
      removeAsync in interface RListAsync<V>
      Overrides:
      removeAsync in class RedissonList<V>
      Parameters:
      o - - element to find
      count - - amount occurrences
      Returns:
      true if at least one element removed; or false if element isn't found
    • removeFirstOccurrenceAsync

      public RFuture<Boolean> removeFirstOccurrenceAsync(Object o)
      Description copied from interface: RDequeAsync
      Removes first occurrence of element o
      Specified by:
      removeFirstOccurrenceAsync in interface RDequeAsync<V>
      Parameters:
      o - - element to remove
      Returns:
      true if object has been removed otherwise false
    • removeFirstOccurrence

      public boolean removeFirstOccurrence(Object o)
      Specified by:
      removeFirstOccurrence in interface Deque<V>
    • removeFirstAsync

      public RFuture<V> removeFirstAsync()
      Description copied from interface: RDequeAsync
      Retrieves and removes the first element of deque. Returns null if there are no elements in deque.
      Specified by:
      removeFirstAsync in interface RDequeAsync<V>
      Returns:
      element
    • removeLastAsync

      public RFuture<V> removeLastAsync()
      Description copied from interface: RDequeAsync
      Retrieves and removes the last element of deque. Returns null if there are no elements in deque.
      Specified by:
      removeLastAsync in interface RDequeAsync<V>
      Returns:
      element
    • removeLast

      public V removeLast()
      Specified by:
      removeLast in interface Deque<V>
    • removeLastOccurrenceAsync

      public RFuture<Boolean> removeLastOccurrenceAsync(Object o)
      Description copied from interface: RDequeAsync
      Removes last occurrence of element o
      Specified by:
      removeLastOccurrenceAsync in interface RDequeAsync<V>
      Parameters:
      o - - element
      Returns:
      true if object has been removed otherwise false
    • removeLastOccurrence

      public boolean removeLastOccurrence(Object o)
      Specified by:
      removeLastOccurrence in interface Deque<V>
    • descendingStream

      public Stream<V> descendingStream()
      Description copied from interface: RPriorityDeque
      Returns stream of elements contained in this deque in reverse order
      Specified by:
      descendingStream in interface RPriorityDeque<V>
      Returns:
      stream of elements in reverse order
    • pollFirstAsync

      public RFuture<List<V>> pollFirstAsync(int limit)
      Description copied from interface: RDequeAsync
      Retrieves and removes the head elements of this queue. Elements amount limited by limit param.
      Specified by:
      pollFirstAsync in interface RDequeAsync<V>
      Returns:
      list of head elements
    • pollFirst

      public List<V> pollFirst(int limit)
      Description copied from interface: RDeque
      Retrieves and removes the head elements of this queue. Elements amount limited by limit param.
      Specified by:
      pollFirst in interface RDeque<V>
      Returns:
      list of head elements
    • pollLast

      public List<V> pollLast(int limit)
      Description copied from interface: RDeque
      Retrieves and removes the tail elements of this queue. Elements amount limited by limit param.
      Specified by:
      pollLast in interface RDeque<V>
      Returns:
      list of tail elements
    • pollLastAsync

      public RFuture<List<V>> pollLastAsync(int limit)
      Description copied from interface: RDequeAsync
      Retrieves and removes the tail elements of this queue. Elements amount limited by limit param.
      Specified by:
      pollLastAsync in interface RDequeAsync<V>
      Returns:
      list of tail elements
    • move

      public V move(DequeMoveArgs args)
      Description copied from interface: RDeque
      Move element from this deque to the given destination deque. Returns moved element.

      Usage examples:

       V element = deque.move(DequeMoveArgs.pollLast()
                                       .addFirstTo("deque2"));
       
       V elements = deque.move(DequeMoveArgs.pollFirst()
                                       .addLastTo("deque2"));
       

      Requires Redis 6.2.0 and higher.

      Specified by:
      move in interface RDeque<V>
      Parameters:
      args - - arguments object
      Returns:
      moved element
    • moveAsync

      public RFuture<V> moveAsync(DequeMoveArgs args)
      Description copied from interface: RDequeAsync
      Move element from this deque to the given destination deque. Returns moved element.

      Usage examples:

       V element = deque.move(DequeMoveArgs.pollLast()
                                       .addFirstTo("deque2"));
       
       V elements = deque.move(DequeMoveArgs.pollFirst()
                                       .addLastTo("deque2"));
       

      Requires Redis 6.2.0 and higher.

      Specified by:
      moveAsync in interface RDequeAsync<V>
      Parameters:
      args - - arguments object
      Returns:
      moved element
    • 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)