Package org.redisson
Class RedissonSubList<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonList<V>
-
- org.redisson.RedissonSubList<V>
-
- Type Parameters:
V
- the type of elements held in this collection
- All Implemented Interfaces:
Iterable<V>
,Collection<V>
,List<V>
,RandomAccess
,RCollectionAsync<V>
,RExpirable
,RExpirableAsync
,RList<V>
,RListAsync<V>
,RObject
,RObjectAsync
,RSortable<List<V>>
,RSortableAsync<List<V>>
public class RedissonSubList<V> extends RedissonList<V> implements RList<V>
Distributed and concurrent implementation ofList
- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RedissonSubList(Codec codec, CommandAsyncExecutor commandExecutor, String name, int fromIndex, int toIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, V element)
RFuture<Boolean>
addAllAsync(int index, Collection<? extends V> coll)
Insertselements
atindex
.RFuture<Boolean>
addAllAsync(Collection<? extends V> c)
Adds all elements contained in the specified collectionRFuture<Boolean>
addAsync(V e)
Adds element into this collection.void
clear()
boolean
clearExpire()
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)
RFuture<Boolean>
containsAllAsync(Collection<?> c)
Returnstrue
if this collection contains all of the elements in the specified collection.boolean
equals(Object o)
boolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.boolean
expire(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.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
expireAt(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)
insteadvoid
fastSet(int index, V element)
Setelement
atindex
.RFuture<Void>
fastSetAsync(int index, V element)
Setelement
atindex
.V
get(int index)
RFuture<V>
getAsync(int index)
Get element atindex
int
hashCode()
<R> RFuture<R>
indexOfAsync(Object o, Convertor<R> convertor)
RFuture<Integer>
lastIndexOfAsync(Object o)
Returns last index ofelement
or -1 if element isn't foundListIterator<V>
listIterator()
ListIterator<V>
listIterator(int fromIndex)
RFuture<List<V>>
readAllAsync()
Read all elements at oncelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutV
remove(int index)
RFuture<Boolean>
removeAllAsync(Collection<?> c)
Removes all of this collection's elements that are also contained in the specified collection.RFuture<Boolean>
removeAsync(Object o)
Removes a single instance of the specified element from this collection, if it is present.RFuture<Boolean>
retainAllAsync(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection.V
set(int index, V element)
RFuture<V>
setAsync(int index, V element)
Setelement
atindex
and returns previous element.RFuture<Integer>
sizeAsync()
Returns number of elements in this collection.RList<V>
subList(int fromIndex, int toIndex)
String
toString()
void
trim(int fromIndex, int toIndex)
Trim list and remains elements only in specified rangefromIndex
, inclusive, andtoIndex
, inclusive.RFuture<Void>
trimAsync(int fromIndex, int toIndex)
Trim list and remains elements only in specified rangefromIndex
, inclusive, andtoIndex
, inclusive.-
Methods inherited from class org.redisson.RedissonList
add, addAfter, addAfterAsync, addAll, addAll, addAsync, addAsync, addBefore, addBeforeAsync, addListener, addListenerAsync, contains, containsAll, containsAsync, fastRemove, fastRemoveAsync, get, getAsync, indexOf, indexOfAsync, isEmpty, iterator, lastIndexOf, lastIndexOfAsync, mapReduce, range, range, rangeAsync, rangeAsync, readAll, 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, removeAll, removeAsync, removeAsync, removeIf, removeListener, removeListenerAsync, retainAll, size, sortTo, sortTo, sortTo, sortTo, sortTo, sortTo, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, toArray, toArray
-
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.List
add, addAll, addAll, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArray
-
Methods inherited from interface org.redisson.api.RCollectionAsync
containsAsync
-
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.RList
addAfter, addBefore, addListener, fastRemove, get, mapReduce, range, range, readAll, remove
-
Methods inherited from interface org.redisson.api.RListAsync
addAfterAsync, addAsync, addBeforeAsync, addListenerAsync, fastRemoveAsync, getAsync, indexOfAsync, rangeAsync, rangeAsync, removeAsync, removeAsync
-
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.RSortable
readSort, readSort, readSort, readSort, readSort, readSort, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, readSortAlpha, sortTo, sortTo, sortTo, sortTo, sortTo, sortTo
-
Methods inherited from interface org.redisson.api.RSortableAsync
readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAlphaAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, readSortAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync, sortToAsync
-
-
-
-
Constructor Detail
-
RedissonSubList
protected RedissonSubList(Codec codec, CommandAsyncExecutor commandExecutor, String name, int fromIndex, int toIndex)
-
-
Method Detail
-
sizeAsync
public RFuture<Integer> sizeAsync()
Description copied from interface:RCollectionAsync
Returns number of elements in this collection.- Specified by:
sizeAsync
in interfaceRCollectionAsync<V>
- Overrides:
sizeAsync
in classRedissonList<V>
- Returns:
- size of collection
-
readAllAsync
public RFuture<List<V>> readAllAsync()
Description copied from interface:RListAsync
Read all elements at once- Specified by:
readAllAsync
in interfaceRListAsync<V>
- Overrides:
readAllAsync
in classRedissonList<V>
- Returns:
- list of values
-
addAsync
public RFuture<Boolean> addAsync(V e)
Description copied from interface:RCollectionAsync
Adds element into this collection.- Specified by:
addAsync
in interfaceRCollectionAsync<V>
- Overrides:
addAsync
in classRedissonList<V>
- Parameters:
e
- - element to add- Returns:
true
if an element was added andfalse
if it is already present
-
removeAsync
public RFuture<Boolean> removeAsync(Object o)
Description copied from interface:RCollectionAsync
Removes a single instance of the specified element from this collection, if it is present.- Specified by:
removeAsync
in interfaceRCollectionAsync<V>
- Overrides:
removeAsync
in classRedissonList<V>
- Parameters:
o
- element to be removed from this collection, if present- Returns:
true
if an element was removed as a result of this call
-
containsAllAsync
public RFuture<Boolean> containsAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsync
Returnstrue
if this collection contains all of the elements in the specified collection.- Specified by:
containsAllAsync
in interfaceRCollectionAsync<V>
- Overrides:
containsAllAsync
in classRedissonList<V>
- Parameters:
c
- collection to be checked for containment in this collection- Returns:
true
if this collection contains all of the elements in the specified collection
-
addAllAsync
public RFuture<Boolean> addAllAsync(Collection<? extends V> c)
Description copied from interface:RCollectionAsync
Adds all elements contained in the specified collection- Specified by:
addAllAsync
in interfaceRCollectionAsync<V>
- Overrides:
addAllAsync
in classRedissonList<V>
- Parameters:
c
- - collection of elements to add- Returns:
true
if at least one element was added andfalse
if all elements are already present
-
addAllAsync
public RFuture<Boolean> addAllAsync(int index, Collection<? extends V> coll)
Description copied from interface:RListAsync
Insertselements
atindex
. Subsequent elements are shifted.- Specified by:
addAllAsync
in interfaceRListAsync<V>
- Overrides:
addAllAsync
in classRedissonList<V>
- Parameters:
index
- - index numbercoll
- - elements to insert- Returns:
true
if list changed orfalse
if element isn't found
-
removeAllAsync
public RFuture<Boolean> removeAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsync
Removes all of this collection's elements that are also contained in the specified collection.- Specified by:
removeAllAsync
in interfaceRCollectionAsync<V>
- Overrides:
removeAllAsync
in classRedissonList<V>
- Parameters:
c
- collection containing elements to be removed from this collection- Returns:
true
if this collection changed as a result of the call
-
retainAllAsync
public RFuture<Boolean> retainAllAsync(Collection<?> c)
Description copied from interface:RCollectionAsync
Retains only the elements in this collection that are contained in the specified collection.- Specified by:
retainAllAsync
in interfaceRCollectionAsync<V>
- Overrides:
retainAllAsync
in classRedissonList<V>
- Parameters:
c
- collection containing elements to be retained in this collection- Returns:
true
if this collection changed as a result of the call
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<V>
- Specified by:
clear
in interfaceList<V>
- Overrides:
clear
in classRedissonList<V>
-
getAsync
public RFuture<V> getAsync(int index)
Description copied from interface:RListAsync
Get element atindex
- Specified by:
getAsync
in interfaceRListAsync<V>
- Overrides:
getAsync
in classRedissonList<V>
- Parameters:
index
- - index of object- Returns:
- element
-
get
public V get(int index)
-
setAsync
public RFuture<V> setAsync(int index, V element)
Description copied from interface:RListAsync
Setelement
atindex
and returns previous element.- Specified by:
setAsync
in interfaceRListAsync<V>
- Overrides:
setAsync
in classRedissonList<V>
- Parameters:
index
- - index of objectelement
- - object- Returns:
- previous element or
null
if element wasn't set.
-
fastSetAsync
public RFuture<Void> fastSetAsync(int index, V element)
Description copied from interface:RListAsync
Setelement
atindex
. Works faster thanRListAsync.setAsync(int, Object)
but doesn't return previous element.- Specified by:
fastSetAsync
in interfaceRListAsync<V>
- Overrides:
fastSetAsync
in classRedissonList<V>
- Parameters:
index
- - index of objectelement
- - object- Returns:
- void
-
add
public void add(int index, V element)
-
remove
public V remove(int index)
-
indexOfAsync
public <R> RFuture<R> indexOfAsync(Object o, Convertor<R> convertor)
- Overrides:
indexOfAsync
in classRedissonList<V>
-
lastIndexOfAsync
public RFuture<Integer> lastIndexOfAsync(Object o)
Description copied from interface:RListAsync
Returns last index ofelement
or -1 if element isn't found- Specified by:
lastIndexOfAsync
in interfaceRListAsync<V>
- Overrides:
lastIndexOfAsync
in classRedissonList<V>
- Parameters:
o
- to find- Returns:
- index of -1 if element isn't found
-
listIterator
public ListIterator<V> listIterator()
- Specified by:
listIterator
in interfaceList<V>
- Overrides:
listIterator
in classRedissonList<V>
-
listIterator
public ListIterator<V> listIterator(int fromIndex)
- Specified by:
listIterator
in interfaceList<V>
- Overrides:
listIterator
in classRedissonList<V>
-
trimAsync
public RFuture<Void> trimAsync(int fromIndex, int toIndex)
Description copied from interface:RListAsync
Trim list and remains elements only in specified rangefromIndex
, inclusive, andtoIndex
, inclusive.- Specified by:
trimAsync
in interfaceRListAsync<V>
- Overrides:
trimAsync
in classRedissonList<V>
- Parameters:
fromIndex
- - from indextoIndex
- - to index- Returns:
- void
-
trim
public void trim(int fromIndex, int toIndex)
Description copied from interface:RList
Trim list and remains elements only in specified rangefromIndex
, inclusive, andtoIndex
, inclusive.
-
toString
public String toString()
- Overrides:
toString
in classRedissonList<V>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<V>
- Specified by:
equals
in interfaceList<V>
- Overrides:
equals
in classRedissonList<V>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<V>
- Specified by:
hashCode
in interfaceList<V>
- Overrides:
hashCode
in classRedissonList<V>
-
expire
public boolean expire(long timeToLive, TimeUnit 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 RFuture<Boolean> expireAsync(long timeToLive, TimeUnit 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 RFuture<Boolean> 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 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 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 interfaceRExpirableAsync
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date 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 RFuture<Boolean> expireAtAsync(Date 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 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 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 RFuture<Long> 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 RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
-
-