public abstract class RedissonObject extends Object implements RObject
Modifier and Type | Field and Description |
---|---|
protected Codec |
codec |
protected CommandAsyncExecutor |
commandExecutor |
protected String |
name |
Constructor and Description |
---|
RedissonObject(Codec codec,
CommandAsyncExecutor commandExecutor,
String name) |
RedissonObject(CommandAsyncExecutor commandExecutor,
String name) |
Modifier and Type | Method and Description |
---|---|
int |
addListener(ObjectListener listener)
Adds object event listener
|
protected <T extends ObjectListener> |
addListener(String name,
T listener,
BiConsumer<T,String> consumer) |
RFuture<Integer> |
addListenerAsync(ObjectListener listener)
Adds object event listener
|
protected <T extends ObjectListener> |
addListenerAsync(String name,
T listener,
BiConsumer<T,String> consumer) |
void |
copy(String host,
int port,
int database,
long timeout)
Copy object from source Redis instance to destination Redis instance
|
RFuture<Void> |
copyAsync(String host,
int port,
int database,
long timeout)
Copy object from source Redis instance to destination Redis instance
in async mode
|
boolean |
delete()
Deletes the object
|
RFuture<Boolean> |
deleteAsync()
Delete object in async mode
|
protected RFuture<Boolean> |
deleteAsync(String... keys) |
byte[] |
dump()
Returns dump of object
|
RFuture<byte[]> |
dumpAsync()
Returns dump of object
|
protected List<io.netty.buffer.ByteBuf> |
encode(Collection<?> values) |
void |
encode(Collection<Object> params,
Collection<?> values) |
protected List<io.netty.buffer.ByteBuf> |
encode(Object... values) |
io.netty.buffer.ByteBuf |
encode(Object value) |
io.netty.buffer.ByteBuf |
encodeMapKey(Object value) |
protected void |
encodeMapKeys(Collection<Object> params,
Collection<?> values) |
io.netty.buffer.ByteBuf |
encodeMapValue(Object value) |
protected void |
encodeMapValues(Collection<Object> params,
Collection<?> values) |
protected <V> V |
get(RFuture<V> future) |
Codec |
getCodec()
Returns the underlying Codec used by this RObject
|
Long |
getIdleTime()
Returns number of seconds spent since last write or read operation over this object.
|
RFuture<Long> |
getIdleTimeAsync()
Returns number of seconds spent since last write or read operation over this object.
|
String |
getLockByMapKey(Object key,
String suffix) |
String |
getLockByValue(Object key,
String suffix) |
String |
getName()
Returns name of object
|
protected String |
getName(Object o) |
boolean |
isExists()
Check object existence
|
RFuture<Boolean> |
isExistsAsync()
Check object existence in async mode.
|
void |
migrate(String host,
int port,
int database,
long timeout)
Copy object from source Redis instance to destination Redis instance
|
RFuture<Void> |
migrateAsync(String host,
int port,
int database,
long timeout)
Transfer object from source Redis instance to destination Redis instance
in async mode
|
boolean |
move(int database)
Move object to another database
|
RFuture<Boolean> |
moveAsync(int database)
Move object to another database in async mode
|
static String |
prefixName(String prefix,
String name) |
void |
removeListener(int listenerId)
Removes object event listener
|
RFuture<Void> |
removeListenerAsync(int listenerId)
Removes object event listener
|
protected void |
removeListenersAsync(int listenerId,
CountableListener<Void> listener) |
void |
rename(String newName)
Rename current object key to
newName |
RFuture<Void> |
renameAsync(String newName)
Rename current object key to
newName
in async mode |
boolean |
renamenx(String newName)
Rename current object key to
newName
only if new key is not exists |
RFuture<Boolean> |
renamenxAsync(String newName)
Rename current object key to
newName
in async mode only if new key is not exists |
void |
restore(byte[] state)
Restores object using its state returned by
RObject.dump() method. |
void |
restore(byte[] state,
long timeToLive,
TimeUnit timeUnit)
Restores object using its state returned by
RObject.dump() method and set time to live for it. |
void |
restoreAndReplace(byte[] state)
Restores and replaces object if it already exists.
|
void |
restoreAndReplace(byte[] state,
long timeToLive,
TimeUnit timeUnit)
Restores and replaces object if it already exists and set time to live for it.
|
RFuture<Void> |
restoreAndReplaceAsync(byte[] state)
Restores and replaces object if it already exists.
|
RFuture<Void> |
restoreAndReplaceAsync(byte[] state,
long timeToLive,
TimeUnit timeUnit)
Restores and replaces object if it already exists and set time to live for it.
|
RFuture<Void> |
restoreAsync(byte[] state)
Restores object using its state returned by
RObjectAsync.dumpAsync() method. |
RFuture<Void> |
restoreAsync(byte[] state,
long timeToLive,
TimeUnit timeUnit)
Restores object using its state returned by
RObjectAsync.dumpAsync() method and set time to live for it. |
protected void |
setName(String name) |
long |
sizeInMemory()
Returns bytes amount used by object in Redis memory.
|
RFuture<Long> |
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.
|
RFuture<Long> |
sizeInMemoryAsync(CommandAsyncExecutor commandExecutor,
List<Object> keys) |
RFuture<Long> |
sizeInMemoryAsync(List<Object> keys) |
static String |
suffixName(String name,
String suffix) |
protected long |
toSeconds(long timeout,
TimeUnit unit) |
protected <T> Stream<T> |
toStream(Iterator<T> iterator) |
boolean |
touch()
Update the last access time of an object.
|
RFuture<Boolean> |
touchAsync()
Update the last access time of an object in async mode.
|
boolean |
unlink()
Delete the objects.
|
RFuture<Boolean> |
unlinkAsync()
Delete the objects.
|
protected final CommandAsyncExecutor commandExecutor
protected String name
protected final Codec codec
public RedissonObject(Codec codec, CommandAsyncExecutor commandExecutor, String name)
public RedissonObject(CommandAsyncExecutor commandExecutor, String name)
protected final <V> V get(RFuture<V> future)
protected final long toSeconds(long timeout, TimeUnit unit)
public final String getName()
RObject
protected final void setName(String name)
public void rename(String newName)
RObject
newName
public RFuture<Long> sizeInMemoryAsync()
RObjectAsync
sizeInMemoryAsync
in interface RObjectAsync
public final RFuture<Long> sizeInMemoryAsync(CommandAsyncExecutor commandExecutor, List<Object> keys)
public long sizeInMemory()
RObject
sizeInMemory
in interface RObject
public RFuture<Void> renameAsync(String newName)
RObjectAsync
newName
in async moderenameAsync
in interface RObjectAsync
newName
- - new name of objectpublic void migrate(String host, int port, int database, long timeout)
RObject
public RFuture<Void> migrateAsync(String host, int port, int database, long timeout)
RObjectAsync
migrateAsync
in interface RObjectAsync
host
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in millisecondspublic void copy(String host, int port, int database, long timeout)
RObject
public RFuture<Void> copyAsync(String host, int port, int database, long timeout)
RObjectAsync
copyAsync
in interface RObjectAsync
host
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in millisecondspublic boolean move(int database)
RObject
public RFuture<Boolean> moveAsync(int database)
RObjectAsync
moveAsync
in interface RObjectAsync
database
- - number of Redis databasetrue
if key was moved false
if notpublic boolean renamenx(String newName)
RObject
newName
only if new key is not existspublic RFuture<Boolean> renamenxAsync(String newName)
RObjectAsync
newName
in async mode only if new key is not existsrenamenxAsync
in interface RObjectAsync
newName
- - new name of objecttrue
if object has been renamed successfully and false
otherwisepublic boolean delete()
RObject
public RFuture<Boolean> deleteAsync()
RObjectAsync
deleteAsync
in interface RObjectAsync
true
if object was deleted false
if notpublic boolean unlink()
RObject
Requires Redis 4.0+
public RFuture<Boolean> unlinkAsync()
RObjectAsync
Requires Redis 4.0+
unlinkAsync
in interface RObjectAsync
true
if it was exist and deleted else false
public boolean touch()
RObject
public RFuture<Boolean> touchAsync()
RObjectAsync
touchAsync
in interface RObjectAsync
true
if object was touched else false
public boolean isExists()
RObject
public RFuture<Boolean> isExistsAsync()
RObjectAsync
isExistsAsync
in interface RObjectAsync
true
if object exists and false
otherwisepublic Codec getCodec()
RObject
protected List<io.netty.buffer.ByteBuf> encode(Collection<?> values)
public void encode(Collection<Object> params, Collection<?> values)
protected void encodeMapKeys(Collection<Object> params, Collection<?> values)
protected void encodeMapValues(Collection<Object> params, Collection<?> values)
public io.netty.buffer.ByteBuf encode(Object value)
public io.netty.buffer.ByteBuf encodeMapKey(Object value)
public io.netty.buffer.ByteBuf encodeMapValue(Object value)
public byte[] dump()
RObject
public RFuture<byte[]> dumpAsync()
RObjectAsync
dumpAsync
in interface RObjectAsync
public void restore(byte[] state)
RObject
RObject.dump()
method.public RFuture<Void> restoreAsync(byte[] state)
RObjectAsync
RObjectAsync.dumpAsync()
method.restoreAsync
in interface RObjectAsync
state
- - state of objectpublic void restore(byte[] state, long timeToLive, TimeUnit timeUnit)
RObject
RObject.dump()
method and set time to live for it.public RFuture<Void> restoreAsync(byte[] state, long timeToLive, TimeUnit timeUnit)
RObjectAsync
RObjectAsync.dumpAsync()
method and set time to live for it.restoreAsync
in interface RObjectAsync
state
- - state of objecttimeToLive
- - time to live of the objecttimeUnit
- - time unitpublic void restoreAndReplace(byte[] state, long timeToLive, TimeUnit timeUnit)
RObject
restoreAndReplace
in interface RObject
state
- - state of the objecttimeToLive
- - time to live of the objecttimeUnit
- - time unitpublic RFuture<Void> restoreAndReplaceAsync(byte[] state, long timeToLive, TimeUnit timeUnit)
RObjectAsync
restoreAndReplaceAsync
in interface RObjectAsync
state
- - state of the objecttimeToLive
- - time to live of the objecttimeUnit
- - time unitpublic void restoreAndReplace(byte[] state)
RObject
restoreAndReplace
in interface RObject
state
- - state of the objectpublic RFuture<Void> restoreAndReplaceAsync(byte[] state)
RObjectAsync
restoreAndReplaceAsync
in interface RObjectAsync
state
- - state of the objectpublic Long getIdleTime()
RObject
getIdleTime
in interface RObject
public RFuture<Long> getIdleTimeAsync()
RObjectAsync
getIdleTimeAsync
in interface RObjectAsync
protected final <T extends ObjectListener> int addListener(String name, T listener, BiConsumer<T,String> consumer)
protected final <T extends ObjectListener> RFuture<Integer> addListenerAsync(String name, T listener, BiConsumer<T,String> consumer)
public int addListener(ObjectListener listener)
RObject
addListener
in interface RObject
listener
- - object event listenerExpiredObjectListener
,
DeletedObjectListener
public RFuture<Integer> addListenerAsync(ObjectListener listener)
RObjectAsync
addListenerAsync
in interface RObjectAsync
listener
- - object event listenerExpiredObjectListener
,
DeletedObjectListener
public void removeListener(int listenerId)
RObject
removeListener
in interface RObject
listenerId
- - listener idpublic RFuture<Void> removeListenerAsync(int listenerId)
RObjectAsync
removeListenerAsync
in interface RObjectAsync
listenerId
- - listener idprotected final void removeListenersAsync(int listenerId, CountableListener<Void> listener)
Copyright © 2014–2021 Redisson. All rights reserved.