Package org.redisson
Class RedissonDeque<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonList<V>
-
- org.redisson.RedissonQueue<V>
-
- org.redisson.RedissonDeque<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,RQueue<V>,RQueueAsync<V>,RSortable<List<V>>,RSortableAsync<List<V>>
- Direct Known Subclasses:
RedissonBlockingDeque
public class RedissonDeque<V> extends RedissonQueue<V> implements RDeque<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 RedissonDeque(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)RedissonDeque(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFirst(V e)RFuture<Void>addFirstAsync(V e)Adds element at the head of this deque.intaddFirstIfExists(V... elements)Adds element at the head of existing deque.RFuture<Integer>addFirstIfExistsAsync(V... elements)Adds element at the head of existing deque.voidaddLast(V e)RFuture<Void>addLastAsync(V e)Adds element at the tail of this deque.intaddLastIfExists(V... elements)Adds element at the tail of existing deque.RFuture<Integer>addLastIfExistsAsync(V... elements)Adds element at the tail of existing deque.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)Iterator<V>descendingIterator()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)insteadVgetLast()RFuture<V>getLastAsync()Returns element at the tail of this deque ornullif there are no elements in deque.Vmove(DequeMoveArgs args)Move element from this deque to the given destination deque.RFuture<V>moveAsync(DequeMoveArgs args)Move element from this deque to the given destination deque.booleanofferFirst(V e)RFuture<Boolean>offerFirstAsync(V e)Adds element at the head of this deque.booleanofferLast(V e)RFuture<Boolean>offerLastAsync(V e)Adds element at the tail of this deque.VpeekFirst()RFuture<V>peekFirstAsync()Returns element at the head of this deque ornullif there are no elements in deque.VpeekLast()RFuture<V>peekLastAsync()Returns element at the tail of this deque ornullif there are no elements in deque.VpollFirst()List<V>pollFirst(int limit)Retrieves and removes the head elements of this queue.RFuture<V>pollFirstAsync()Retrieves and removes element at the head of this deque.RFuture<List<V>>pollFirstAsync(int limit)Retrieves and removes the head elements of this queue.VpollLast()List<V>pollLast(int limit)Retrieves and removes the tail elements of this queue.RFuture<V>pollLastAsync()Retrieves and removes element at the tail of this deque.RFuture<List<V>>pollLastAsync(int limit)Retrieves and removes the tail elements of this queue.Vpop()RFuture<V>popAsync()Retrieves and removes element at the head of this deque.voidpush(V e)RFuture<Void>pushAsync(V e)Adds element at the head of this deque.longremainTimeToLive()Remaining time to live of Redisson object that has a timeoutRFuture<Long>remainTimeToLiveAsync()Remaining time to live of Redisson object that has a timeoutRFuture<V>removeFirstAsync()Retrieves and removes the first element of deque.booleanremoveFirstOccurrence(Object o)RFuture<Boolean>removeFirstOccurrenceAsync(Object o)Removes first occurrence of elementoVremoveLast()RFuture<V>removeLastAsync()Retrieves and removes the last element of deque.booleanremoveLastOccurrence(Object o)RFuture<Boolean>removeLastOccurrenceAsync(Object o)Removes last occurrence of elemento-
Methods inherited from class org.redisson.RedissonQueue
element, getFirst, offer, offerAsync, peek, peekAsync, poll, poll, pollAsync, pollAsync, pollLastAndOfferFirstTo, pollLastAndOfferFirstToAsync, remove, removeFirst
-
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.Deque
add, addAll, contains, element, getFirst, iterator, offer, peek, poll, remove, remove, removeFirst, size
-
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, poll, pollLastAndOfferFirstTo, readAll
-
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync, offerAsync, peekAsync, pollAsync, pollAsync, pollLastAndOfferFirstToAsync, readAllAsync
-
-
-
-
Constructor Detail
-
RedissonDeque
public RedissonDeque(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
RedissonDeque
public RedissonDeque(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson)
-
-
Method Detail
-
addFirstIfExists
public int addFirstIfExists(V... elements)
Description copied from interface:RDequeAdds element at the head of existing deque.- Specified by:
addFirstIfExistsin interfaceRDeque<V>- Parameters:
elements- - elements to add- Returns:
- length of the list
-
addLastIfExists
public int addLastIfExists(V... elements)
Description copied from interface:RDequeAdds element at the tail of existing deque.- Specified by:
addLastIfExistsin interfaceRDeque<V>- Parameters:
elements- - elements to add- Returns:
- length of the list
-
addFirstIfExistsAsync
public RFuture<Integer> addFirstIfExistsAsync(V... elements)
Description copied from interface:RDequeAsyncAdds element at the head of existing deque.- Specified by:
addFirstIfExistsAsyncin interfaceRDequeAsync<V>- Parameters:
elements- - elements to add- Returns:
- length of the list
-
addLastIfExistsAsync
public RFuture<Integer> addLastIfExistsAsync(V... elements)
Description copied from interface:RDequeAsyncAdds element at the tail of existing deque.- Specified by:
addLastIfExistsAsyncin interfaceRDequeAsync<V>- Parameters:
elements- - elements to add- Returns:
- length of the list
-
addFirstAsync
public RFuture<Void> addFirstAsync(V e)
Description copied from interface:RDequeAsyncAdds element at the head of this deque.- Specified by:
addFirstAsyncin interfaceRDequeAsync<V>- Parameters:
e- - element to add- Returns:
- void
-
addLastAsync
public RFuture<Void> addLastAsync(V e)
Description copied from interface:RDequeAsyncAdds element at the tail of this deque.- Specified by:
addLastAsyncin interfaceRDequeAsync<V>- Parameters:
e- - element to add- Returns:
- void
-
move
public V move(DequeMoveArgs args)
Description copied from interface:RDequeMove 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.
-
moveAsync
public RFuture<V> moveAsync(DequeMoveArgs args)
Description copied from interface:RDequeAsyncMove 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:
moveAsyncin interfaceRDequeAsync<V>- Parameters:
args- - arguments object- Returns:
- moved element
-
descendingIterator
public Iterator<V> descendingIterator()
- Specified by:
descendingIteratorin interfaceDeque<V>
-
getLastAsync
public RFuture<V> getLastAsync()
Description copied from interface:RDequeAsyncReturns element at the tail of this deque ornullif there are no elements in deque.- Specified by:
getLastAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
offerFirst
public boolean offerFirst(V e)
- Specified by:
offerFirstin interfaceDeque<V>
-
offerFirstAsync
public RFuture<Boolean> offerFirstAsync(V e)
Description copied from interface:RDequeAsyncAdds element at the head of this deque.- Specified by:
offerFirstAsyncin interfaceRDequeAsync<V>- Parameters:
e- - element to add- Returns:
trueif element was added to this deque otherwisefalse
-
offerLastAsync
public RFuture<Boolean> offerLastAsync(V e)
Description copied from interface:RDequeAsyncAdds element at the tail of this deque.- Specified by:
offerLastAsyncin interfaceRDequeAsync<V>- Parameters:
e- - element to add- Returns:
trueif element was added to this deque otherwisefalse
-
peekFirstAsync
public RFuture<V> peekFirstAsync()
Description copied from interface:RDequeAsyncReturns element at the head of this deque ornullif there are no elements in deque.- Specified by:
peekFirstAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
peekLastAsync
public RFuture<V> peekLastAsync()
Description copied from interface:RDequeAsyncReturns element at the tail of this deque ornullif there are no elements in deque.- Specified by:
peekLastAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
pollFirstAsync
public RFuture<V> pollFirstAsync()
Description copied from interface:RDequeAsyncRetrieves and removes element at the head of this deque. Returnsnullif there are no elements in deque.- Specified by:
pollFirstAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
pollFirstAsync
public RFuture<List<V>> pollFirstAsync(int limit)
Description copied from interface:RDequeAsyncRetrieves and removes the head elements of this queue. Elements amount limited bylimitparam.- Specified by:
pollFirstAsyncin interfaceRDequeAsync<V>- Returns:
- list of head elements
-
pollFirst
public List<V> pollFirst(int limit)
Description copied from interface:RDequeRetrieves and removes the head elements of this queue. Elements amount limited bylimitparam.
-
pollLastAsync
public RFuture<V> pollLastAsync()
Description copied from interface:RDequeAsyncRetrieves and removes element at the tail of this deque. Returnsnullif there are no elements in deque.- Specified by:
pollLastAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
pollLast
public List<V> pollLast(int limit)
Description copied from interface:RDequeRetrieves and removes the tail elements of this queue. Elements amount limited bylimitparam.
-
pollLastAsync
public RFuture<List<V>> pollLastAsync(int limit)
Description copied from interface:RDequeAsyncRetrieves and removes the tail elements of this queue. Elements amount limited bylimitparam.- Specified by:
pollLastAsyncin interfaceRDequeAsync<V>- Returns:
- list of tail elements
-
popAsync
public RFuture<V> popAsync()
Description copied from interface:RDequeAsyncRetrieves and removes element at the head of this deque. Returnsnullif there are no elements in deque.- Specified by:
popAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
pushAsync
public RFuture<Void> pushAsync(V e)
Description copied from interface:RDequeAsyncAdds element at the head of this deque.- Specified by:
pushAsyncin interfaceRDequeAsync<V>- Parameters:
e- - element to add- Returns:
- void
-
removeFirstOccurrenceAsync
public RFuture<Boolean> removeFirstOccurrenceAsync(Object o)
Description copied from interface:RDequeAsyncRemoves first occurrence of elemento- Specified by:
removeFirstOccurrenceAsyncin interfaceRDequeAsync<V>- Parameters:
o- - element to remove- Returns:
trueif object has been removed otherwisefalse
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Object o)
- Specified by:
removeFirstOccurrencein interfaceDeque<V>
-
removeFirstAsync
public RFuture<V> removeFirstAsync()
Description copied from interface:RDequeAsyncRetrieves and removes the first element of deque. Returnsnullif there are no elements in deque.- Specified by:
removeFirstAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
removeLastAsync
public RFuture<V> removeLastAsync()
Description copied from interface:RDequeAsyncRetrieves and removes the last element of deque. Returnsnullif there are no elements in deque.- Specified by:
removeLastAsyncin interfaceRDequeAsync<V>- Returns:
- element
-
removeLast
public V removeLast()
- Specified by:
removeLastin interfaceDeque<V>
-
removeLastOccurrenceAsync
public RFuture<Boolean> removeLastOccurrenceAsync(Object o)
Description copied from interface:RDequeAsyncRemoves last occurrence of elemento- Specified by:
removeLastOccurrenceAsyncin interfaceRDequeAsync<V>- Parameters:
o- - element- Returns:
trueif object has been removed otherwisefalse
-
removeLastOccurrence
public boolean removeLastOccurrence(Object o)
- Specified by:
removeLastOccurrencein interfaceDeque<V>
-
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)
-
-