Package org.redisson
Class RedissonDeque<V>
-
- 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:
<V>
,<V>
,<V>
,<V>
,<V>
,,
<V>>
,<V>>
- Direct Known Subclasses:
RedissonBlockingDeque
public class RedissonDeque<V> extends RedissonQueue<V> implements RDeque<V>
Distributed and concurrent implementation of- 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, name, RedissonClient redisson)
RedissonDeque(CommandAsyncExecutor commandExecutor, name, RedissonClient redisson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFirst(V e)
>
addFirstAsync(V e)
Adds element at the head of this deque.int
addFirstIfExists(V... elements)
Adds element at the head of existing deque.>
addFirstIfExistsAsync(V... elements)
Adds element at the head of existing deque.void
addLast(V e)
>
addLastAsync(V e)
Adds element at the tail of this deque.int
addLastIfExists(V... elements)
Adds element at the tail of existing deque.>
addLastIfExistsAsync(V... elements)
Adds element at the tail of existing deque.boolean
clearExpire()
Clear an expire timeout or expire date for object.>
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.protected >
... keys)
<V>
descendingIterator()
boolean
expire(long timeToLive, timeUnit)
Set a timeout for object.boolean
instant)
Set an expire date for object.>
expireAsync(long timeToLive, timeUnit)
Set a timeout for object in async mode.protected >
expireAsync(long timeToLive, timeUnit, ... keys)
>
instant)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
timestamp)
UseRExpirable.expire(Instant)
instead>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected >
expireAtAsync(long timestamp, ... keys)
>
timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadV
getLast()
RFuture<V>
getLastAsync()
Returns element at the tail of this deque ornull
if there are no elements in deque.V
move(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.boolean
offerFirst(V e)
>
offerFirstAsync(V e)
Adds element at the head of this deque.boolean
offerLast(V e)
>
offerLastAsync(V e)
Adds element at the tail of this deque.V
peekFirst()
RFuture<V>
peekFirstAsync()
Returns element at the head of this deque ornull
if there are no elements in deque.V
peekLast()
RFuture<V>
peekLastAsync()
Returns element at the tail of this deque ornull
if there are no elements in deque.V
pollFirst()
<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.<V>>
pollFirstAsync(int limit)
Retrieves and removes the head elements of this queue.V
pollLast()
<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.<V>>
pollLastAsync(int limit)
Retrieves and removes the tail elements of this queue.V
pop()
RFuture<V>
popAsync()
Retrieves and removes element at the head of this deque.void
push(V e)
>
pushAsync(V e)
Adds element at the head of this deque.long
remainTimeToLive()
Remaining time to live of Redisson object that has a timeout>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutRFuture<V>
removeFirstAsync()
Retrieves and removes the first element of deque.boolean
o)
>
o)
Removes first occurrence of elemento
V
removeLast()
RFuture<V>
removeLastAsync()
Retrieves and removes the last element of deque.boolean
o)
>
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 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, name, RedissonClient redisson)
-
RedissonDeque
public RedissonDeque(Codec codec, CommandAsyncExecutor commandExecutor, name, RedissonClient redisson)
-
-
Method Detail
-
addFirstIfExists
public int addFirstIfExists(V... elements)
Description copied from interface:RDeque
Adds element at the head of existing deque.- Specified by:
addFirstIfExists
in interfaceRDeque<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 interfaceRDeque<V>
- Parameters:
elements
- - elements to add- Returns:
- length of the list
-
addFirstIfExistsAsync
public > addFirstIfExistsAsync(V... elements)
Description copied from interface:RDequeAsync
Adds element at the head of existing deque.- Specified by:
addFirstIfExistsAsync
in interfaceRDequeAsync<V>
- Parameters:
elements
- - elements to add- Returns:
- length of the list
-
addLastIfExistsAsync
public > addLastIfExistsAsync(V... elements)
Description copied from interface:RDequeAsync
Adds element at the tail of existing deque.- Specified by:
addLastIfExistsAsync
in interfaceRDequeAsync<V>
- Parameters:
elements
- - elements to add- Returns:
- length of the list
-
addFirstAsync
public > addFirstAsync(V e)
Description copied from interface:RDequeAsync
Adds element at the head of this deque.- Specified by:
addFirstAsync
in interfaceRDequeAsync<V>
- Parameters:
e
- - element to add- Returns:
- void
-
addLastAsync
public > addLastAsync(V e)
Description copied from interface:RDequeAsync
Adds element at the tail of this deque.- Specified by:
addLastAsync
in interfaceRDequeAsync<V>
- Parameters:
e
- - element to add- Returns:
- void
-
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.
-
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 interfaceRDequeAsync<V>
- Parameters:
args
- - arguments object- Returns:
- moved element
-
getLastAsync
public RFuture<V> getLastAsync()
Description copied from interface:RDequeAsync
Returns element at the tail of this deque ornull
if there are no elements in deque.- Specified by:
getLastAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
offerFirstAsync
public > offerFirstAsync(V e)
Description copied from interface:RDequeAsync
Adds element at the head of this deque.- Specified by:
offerFirstAsync
in interfaceRDequeAsync<V>
- Parameters:
e
- - element to add- Returns:
true
if element was added to this deque otherwisefalse
-
offerLastAsync
public > offerLastAsync(V e)
Description copied from interface:RDequeAsync
Adds element at the tail of this deque.- Specified by:
offerLastAsync
in interfaceRDequeAsync<V>
- Parameters:
e
- - element to add- Returns:
true
if element was added to this deque otherwisefalse
-
peekFirstAsync
public RFuture<V> peekFirstAsync()
Description copied from interface:RDequeAsync
Returns element at the head of this deque ornull
if there are no elements in deque.- Specified by:
peekFirstAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
peekLastAsync
public RFuture<V> peekLastAsync()
Description copied from interface:RDequeAsync
Returns element at the tail of this deque ornull
if there are no elements in deque.- Specified by:
peekLastAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
pollFirstAsync
public RFuture<V> pollFirstAsync()
Description copied from interface:RDequeAsync
Retrieves and removes element at the head of this deque. Returnsnull
if there are no elements in deque.- Specified by:
pollFirstAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
pollFirstAsync
public <V>> pollFirstAsync(int limit)
Description copied from interface:RDequeAsync
Retrieves and removes the head elements of this queue. Elements amount limited bylimit
param.- Specified by:
pollFirstAsync
in interfaceRDequeAsync<V>
- Returns:
- list of head elements
-
pollFirst
public <V> pollFirst(int limit)
Description copied from interface:RDeque
Retrieves and removes the head elements of this queue. Elements amount limited bylimit
param.
-
pollLastAsync
public RFuture<V> pollLastAsync()
Description copied from interface:RDequeAsync
Retrieves and removes element at the tail of this deque. Returnsnull
if there are no elements in deque.- Specified by:
pollLastAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
pollLast
public <V> pollLast(int limit)
Description copied from interface:RDeque
Retrieves and removes the tail elements of this queue. Elements amount limited bylimit
param.
-
pollLastAsync
public <V>> pollLastAsync(int limit)
Description copied from interface:RDequeAsync
Retrieves and removes the tail elements of this queue. Elements amount limited bylimit
param.- Specified by:
pollLastAsync
in interfaceRDequeAsync<V>
- Returns:
- list of tail elements
-
popAsync
public RFuture<V> popAsync()
Description copied from interface:RDequeAsync
Retrieves and removes element at the head of this deque. Returnsnull
if there are no elements in deque.- Specified by:
popAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
pushAsync
public > pushAsync(V e)
Description copied from interface:RDequeAsync
Adds element at the head of this deque.- Specified by:
pushAsync
in interfaceRDequeAsync<V>
- Parameters:
e
- - element to add- Returns:
- void
-
removeFirstOccurrenceAsync
public > removeFirstOccurrenceAsync( o)
Description copied from interface:RDequeAsync
Removes first occurrence of elemento
- Specified by:
removeFirstOccurrenceAsync
in interfaceRDequeAsync<V>
- Parameters:
o
- - element to remove- Returns:
true
if object has been removed otherwisefalse
-
removeFirstOccurrence
public boolean removeFirstOccurrence( o)
- Specified by:
in interface
<V>
-
removeFirstAsync
public RFuture<V> removeFirstAsync()
Description copied from interface:RDequeAsync
Retrieves and removes the first element of deque. Returnsnull
if there are no elements in deque.- Specified by:
removeFirstAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
removeLastAsync
public RFuture<V> removeLastAsync()
Description copied from interface:RDequeAsync
Retrieves and removes the last element of deque. Returnsnull
if there are no elements in deque.- Specified by:
removeLastAsync
in interfaceRDequeAsync<V>
- Returns:
- element
-
removeLastOccurrenceAsync
public > removeLastOccurrenceAsync( o)
Description copied from interface:RDequeAsync
Removes last occurrence of elemento
- Specified by:
removeLastOccurrenceAsync
in interfaceRDequeAsync<V>
- Parameters:
o
- - element- Returns:
true
if object has been removed otherwisefalse
-
removeLastOccurrence
public boolean removeLastOccurrence( o)
- Specified by:
in interface
<V>
-
expire
public boolean expire(long timeToLive, 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
-
expireAsync
public > expireAsync(long timeToLive, 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
-
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 > 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)
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 > expireAsync( 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( 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 > expireAtAsync( 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
-
clearExpireAsync
public > 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
-
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 > 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 > expireAsync(long timeToLive, timeUnit, ... keys)
-
expireAtAsync
protected > expireAtAsync(long timestamp, ... keys)
-
clearExpireAsync
protected > clearExpireAsync(... keys)
-
-