Package org.redisson
Class RedissonObject
java.lang.Object
org.redisson.RedissonObject
- All Implemented Interfaces:
RObject
,RObjectAsync
- Direct Known Subclasses:
BaseRedissonList
,JCache
,RedissonAtomicDouble
,RedissonAtomicLong
,RedissonBaseAdder
,RedissonBaseLock
,RedissonBitSet
,RedissonBloomFilter
,RedissonBucket
,RedissonCountDownLatch
,RedissonDelayedQueue
,RedissonHyperLogLog
,RedissonIdGenerator
,RedissonJsonBucket
,RedissonListMultimapValues
,RedissonMap
,RedissonMultimap
,RedissonPermitExpirableSemaphore
,RedissonRateLimiter
,RedissonReadWriteLock
,RedissonReliableTopic
,RedissonScoredSortedSet
,RedissonSemaphore
,RedissonSet
,RedissonSetCache
,RedissonSetMultimapValues
,RedissonSortedSet
,RedissonStream
,RedissonTimeSeries
,RedissonTransferQueue
Base Redisson object
- Author:
- Nikita Koksharov
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Codec
protected CommandAsyncExecutor
protected String
-
Constructor Summary
ConstructorDescriptionRedissonObject
(Codec codec, CommandAsyncExecutor commandExecutor, String name) RedissonObject
(CommandAsyncExecutor commandExecutor, String name) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends ObjectListener>
intaddListener
(String name, T listener, BiConsumer<T, String> consumer) int
addListener
(ObjectListener listener) Adds object event listenerprotected <T extends ObjectListener>
RFuture<Integer> addListenerAsync
(String name, T listener, BiConsumer<T, String> consumer) addListenerAsync
(ObjectListener listener) Adds object event listenerprotected final void
addListenerId
(String name, Integer id) protected final int
addTrackingListener
(TrackingListener listener) addTrackingListenerAsync
(TrackingListener listener) protected final void
final boolean
Copy this object instance to the new instance with a defined name.final boolean
Copy this object instance to the new instance with a defined name and database.void
Copy object from source Redis instance to destination Redis instancefinal boolean
copyAndReplace
(String destination) Copy this object instance to the new instance with a defined name, and replace it if it already exists.final boolean
copyAndReplace
(String destination, int database) Copy this object instance to the new instance with a defined name and database, and replace it if it already exists.copyAndReplaceAsync
(String destination) Copy this object instance to the new instance with a defined name, and replace it if it already exists.copyAndReplaceAsync
(String destination, int database) Copy this object instance to the new instance with a defined name and database, and replace it if it already exists.Copy this object instance to the new instance with a defined name.Copy this object instance to the new instance with a defined name and database.Copy object from source Redis instance to destination Redis instance in async modecopyAsync
(CommandAsyncExecutor commandExecutor, List<Object> keys, int database, boolean replace) boolean
delete()
Deletes the objectDelete object in async modedeleteAsync
(String... keys) byte[]
dump()
Returns dump of objectRFuture
<byte[]> Returns dump of objectio.netty.buffer.ByteBuf
protected List
<io.netty.buffer.ByteBuf> encode
(Collection<?> values) void
encode
(Collection<?> params, Object value) void
encode
(Collection<Object> params, Collection<?> values) final io.netty.buffer.ByteBuf
encodeMapKey
(Object value) final io.netty.buffer.ByteBuf
encodeMapKey
(Object value, Collection<Object> params) protected final void
encodeMapKeys
(Collection<Object> params, Collection<?> values) final io.netty.buffer.ByteBuf
encodeMapValue
(Object value) protected final void
encodeMapValues
(Collection<Object> params, Collection<?> values) protected final <V> V
getCodec()
Returns the underlying Codec used by this RObjectReturns number of seconds spent since last write or read operation over this object.Returns number of seconds spent since last write or read operation over this object.protected final Collection
<Integer> getListenerIdsByName
(String name) final String
getLockByMapKey
(Object key, String suffix) final String
getLockByValue
(Object key, String suffix) getName()
Returns name of objectprotected final String
getNameByListenerId
(int listenerId) final String
protected String
getRawName
(Object o) protected final PublishSubscribeService
boolean
isExists()
Check object existenceCheck object existence in async mode.protected final String
void
Copy object from source Redis instance to destination Redis instancemigrateAsync
(String host, int port, int database, long timeout) Transfer object from source Redis instance to destination Redis instance in async modeboolean
move
(int database) Move object to another databasemoveAsync
(int database) Move object to another database in async modestatic String
prefixName
(String prefix, String name) void
removeListener
(int listenerId) Removes object event listenerprotected final void
removeListener
(int listenerId, String... names) removeListenerAsync
(int listenerId) Removes object event listenerremoveListenerAsync
(int listenerId, String... names) removeListenerAsync
(RFuture<Void> future, int listenerId, String... names) protected final void
removeListenerId
(String name, int listenerId) protected final void
protected final void
removeTrackingListener
(int listenerId) removeTrackingListenerAsync
(int listenerId) void
Rename current object key tonewName
renameAsync
(String newName) Rename current object key tonewName
in async moderenameAsync
(List<Object> keys) renameAsync
(CommandAsyncExecutor commandExecutor, List<Object> keys, Runnable runnable) boolean
Rename current object key tonewName
only if new key is not existsrenamenxAsync
(String newName) Rename current object key tonewName
in async mode only if new key is not existsrenamenxAsync
(List<Object> keys) renamenxAsync
(CommandAsyncExecutor commandExecutor, List<Object> keys, Consumer<Boolean> callback) void
restore
(byte[] state) Restores object using its state returned byRObject.dump()
method.void
Restores object using its state returned byRObject.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.restoreAndReplaceAsync
(byte[] state) Restores and replaces object if it already exists.restoreAndReplaceAsync
(byte[] state, long timeToLive, TimeUnit timeUnit) Restores and replaces object if it already exists and set time to live for it.restoreAsync
(byte[] state) Restores object using its state returned byRObjectAsync.dumpAsync()
method.restoreAsync
(byte[] state, long timeToLive, TimeUnit timeUnit) Restores object using its state returned byRObjectAsync.dumpAsync()
method and set time to live for it.protected void
long
Returns bytes amount used by object in Redis memory.Returns bytes amount used by object in Redis memory.sizeInMemoryAsync
(List<Object> keys) sizeInMemoryAsync
(CommandAsyncExecutor commandExecutor, List<Object> keys) static String
suffixName
(String name, String suffix) protected final long
protected final <T> Stream
<T> boolean
touch()
Update the last access time of an object.Update the last access time of an object in async mode.boolean
unlink()
Delete the objects.Delete the objects.
-
Field Details
-
commandExecutor
-
name
-
codec
-
-
Constructor Details
-
RedissonObject
-
RedissonObject
-
-
Method Details
-
prefixName
-
getServiceManager
-
suffixName
-
toStream
-
get
-
toSeconds
-
getName
Description copied from interface:RObject
Returns name of object -
getRawName
-
getRawName
-
setName
-
rename
Description copied from interface:RObject
Rename current object key tonewName
-
sizeInMemoryAsync
Description copied from interface:RObjectAsync
Returns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsync
in interfaceRObjectAsync
- Returns:
- size in bytes
-
sizeInMemoryAsync
-
sizeInMemoryAsync
public final RFuture<Long> sizeInMemoryAsync(CommandAsyncExecutor commandExecutor, List<Object> keys) -
sizeInMemory
public long sizeInMemory()Description copied from interface:RObject
Returns bytes amount used by object in Redis memory.- Specified by:
sizeInMemory
in interfaceRObject
- Returns:
- size in bytes
-
copyAsync
Description copied from interface:RObjectAsync
Copy this object instance to the new instance with a defined name.- Specified by:
copyAsync
in interfaceRObjectAsync
- Parameters:
destination
- name of the destination instance- Returns:
true
if this object instance was copied elsefalse
-
copyAsync
Description copied from interface:RObjectAsync
Copy this object instance to the new instance with a defined name and database.- Specified by:
copyAsync
in interfaceRObjectAsync
- Parameters:
destination
- name of the destination instancedatabase
- database number- Returns:
true
if this object instance was copied elsefalse
-
copyAndReplaceAsync
Description copied from interface:RObjectAsync
Copy this object instance to the new instance with a defined name, and replace it if it already exists.- Specified by:
copyAndReplaceAsync
in interfaceRObjectAsync
- Parameters:
destination
- name of the destination instance- Returns:
true
if this object instance was copied elsefalse
-
copyAndReplaceAsync
Description copied from interface:RObjectAsync
Copy this object instance to the new instance with a defined name and database, and replace it if it already exists.- Specified by:
copyAndReplaceAsync
in interfaceRObjectAsync
- Parameters:
destination
- name of the destination instancedatabase
- database number- Returns:
true
if this object instance was copied elsefalse
-
copyAsync
-
renameAsync
-
renamenxAsync
-
copyAsync
protected final RFuture<Boolean> copyAsync(CommandAsyncExecutor commandExecutor, List<Object> keys, int database, boolean replace) -
renameAsync
-
renamenxAsync
-
copy
Description copied from interface:RObject
Copy this object instance to the new instance with a defined name. -
copy
Description copied from interface:RObject
Copy this object instance to the new instance with a defined name and database. -
copyAndReplace
Description copied from interface:RObject
Copy this object instance to the new instance with a defined name, and replace it if it already exists.- Specified by:
copyAndReplace
in interfaceRObject
- Parameters:
destination
- name of the destination instance- Returns:
true
if this object instance was copied elsefalse
-
copyAndReplace
Description copied from interface:RObject
Copy this object instance to the new instance with a defined name and database, and replace it if it already exists.- Specified by:
copyAndReplace
in interfaceRObject
- Parameters:
destination
- name of the destination instancedatabase
- database number- Returns:
true
if this object instance was copied elsefalse
-
mapName
-
checkNotBatch
protected final void checkNotBatch() -
renameAsync
Description copied from interface:RObjectAsync
Rename current object key tonewName
in async mode- Specified by:
renameAsync
in interfaceRObjectAsync
- Parameters:
newName
- - new name of object- Returns:
- void
-
migrate
Description copied from interface:RObject
Copy object from source Redis instance to destination Redis instance -
migrateAsync
Description copied from interface:RObjectAsync
Transfer object from source Redis instance to destination Redis instance in async mode- Specified by:
migrateAsync
in interfaceRObjectAsync
- Parameters:
host
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in milliseconds- Returns:
- void
-
copy
Description copied from interface:RObject
Copy object from source Redis instance to destination Redis instance -
copyAsync
Description copied from interface:RObjectAsync
Copy object from source Redis instance to destination Redis instance in async mode- Specified by:
copyAsync
in interfaceRObjectAsync
- Parameters:
host
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in milliseconds- Returns:
- void
-
move
public boolean move(int database) Description copied from interface:RObject
Move object to another database -
moveAsync
Description copied from interface:RObjectAsync
Move object to another database in async mode- Specified by:
moveAsync
in interfaceRObjectAsync
- Parameters:
database
- - number of Redis database- Returns:
true
if key was movedfalse
if not
-
renamenx
Description copied from interface:RObject
Rename current object key tonewName
only if new key is not exists -
renamenxAsync
Description copied from interface:RObjectAsync
Rename current object key tonewName
in async mode only if new key is not exists- Specified by:
renamenxAsync
in interfaceRObjectAsync
- Parameters:
newName
- - new name of object- Returns:
true
if object has been renamed successfully andfalse
otherwise
-
delete
public boolean delete()Description copied from interface:RObject
Deletes the object -
deleteAsync
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Returns:
true
if object was deletedfalse
if not
-
deleteAsync
-
unlink
public boolean unlink()Description copied from interface:RObject
Delete the objects. Actual removal will happen later asynchronously.Requires Redis 4.0+
-
unlinkAsync
Description copied from interface:RObjectAsync
Delete the objects. Actual removal will happen later asynchronously.Requires Redis 4.0+
- Specified by:
unlinkAsync
in interfaceRObjectAsync
- Returns:
true
if it was exist and deleted elsefalse
-
touch
public boolean touch()Description copied from interface:RObject
Update the last access time of an object. -
touchAsync
Description copied from interface:RObjectAsync
Update the last access time of an object in async mode.- Specified by:
touchAsync
in interfaceRObjectAsync
- Returns:
true
if object was touched elsefalse
-
isExists
public boolean isExists()Description copied from interface:RObject
Check object existence -
isExistsAsync
Description copied from interface:RObjectAsync
Check object existence in async mode.- Specified by:
isExistsAsync
in interfaceRObjectAsync
- Returns:
true
if object exists andfalse
otherwise
-
getCodec
Description copied from interface:RObject
Returns the underlying Codec used by this RObject -
encode
-
encode
-
getLockByMapKey
-
getLockByValue
-
encodeMapKeys
-
encodeMapValues
-
encode
-
encode
-
encodeMapKey
-
encodeMapKey
-
encodeMapValue
-
dump
public byte[] dump()Description copied from interface:RObject
Returns dump of object -
dumpAsync
Description copied from interface:RObjectAsync
Returns dump of object- Specified by:
dumpAsync
in interfaceRObjectAsync
- Returns:
- dump
-
restore
public void restore(byte[] state) Description copied from interface:RObject
Restores object using its state returned byRObject.dump()
method. -
restoreAsync
Description copied from interface:RObjectAsync
Restores object using its state returned byRObjectAsync.dumpAsync()
method.- Specified by:
restoreAsync
in interfaceRObjectAsync
- Parameters:
state
- - state of object- Returns:
- void
-
restore
Description copied from interface:RObject
Restores object using its state returned byRObject.dump()
method and set time to live for it. -
restoreAsync
Description copied from interface:RObjectAsync
Restores object using its state returned byRObjectAsync.dumpAsync()
method and set time to live for it.- Specified by:
restoreAsync
in interfaceRObjectAsync
- Parameters:
state
- - state of objecttimeToLive
- - time to live of the objecttimeUnit
- - time unit- Returns:
- void
-
restoreAndReplace
Description copied from interface:RObject
Restores and replaces object if it already exists and set time to live for it.- Specified by:
restoreAndReplace
in interfaceRObject
- Parameters:
state
- - state of the objecttimeToLive
- - time to live of the objecttimeUnit
- - time unit
-
restoreAndReplaceAsync
Description copied from interface:RObjectAsync
Restores and replaces object if it already exists and set time to live for it.- Specified by:
restoreAndReplaceAsync
in interfaceRObjectAsync
- Parameters:
state
- - state of the objecttimeToLive
- - time to live of the objecttimeUnit
- - time unit- Returns:
- void
-
restoreAndReplace
public void restoreAndReplace(byte[] state) Description copied from interface:RObject
Restores and replaces object if it already exists.- Specified by:
restoreAndReplace
in interfaceRObject
- Parameters:
state
- - state of the object
-
restoreAndReplaceAsync
Description copied from interface:RObjectAsync
Restores and replaces object if it already exists.- Specified by:
restoreAndReplaceAsync
in interfaceRObjectAsync
- Parameters:
state
- - state of the object- Returns:
- void
-
getIdleTime
Description copied from interface:RObject
Returns number of seconds spent since last write or read operation over this object.- Specified by:
getIdleTime
in interfaceRObject
- Returns:
- number of seconds
-
getIdleTimeAsync
Description copied from interface:RObjectAsync
Returns number of seconds spent since last write or read operation over this object.- Specified by:
getIdleTimeAsync
in interfaceRObjectAsync
- Returns:
- number of seconds
-
removeListener
-
getListenerIdsByName
-
getNameByListenerId
-
removeListenerId
-
removeListenerAsync
-
addTrackingListener
-
addTrackingListenerAsync
-
addListener
protected <T extends ObjectListener> int addListener(String name, T listener, BiConsumer<T, String> consumer) -
addListenerAsync
protected <T extends ObjectListener> RFuture<Integer> addListenerAsync(String name, T listener, BiConsumer<T, String> consumer) -
addListenerId
-
removeListeners
protected final void removeListeners() -
addListener
Description copied from interface:RObject
Adds object event listener- Specified by:
addListener
in interfaceRObject
- Parameters:
listener
- - object event listener- Returns:
- listener id
- See Also:
-
addListenerAsync
Description copied from interface:RObjectAsync
Adds object event listener- Specified by:
addListenerAsync
in interfaceRObjectAsync
- Parameters:
listener
- - object event listener- Returns:
- listener id
- See Also:
-
removeListener
public void removeListener(int listenerId) Description copied from interface:RObject
Removes object event listener- Specified by:
removeListener
in interfaceRObject
- Parameters:
listenerId
- - listener id
-
removeListenerAsync
Description copied from interface:RObjectAsync
Removes object event listener- Specified by:
removeListenerAsync
in interfaceRObjectAsync
- Parameters:
listenerId
- - listener id
-
removeListenerAsync
-
removeTrackingListener
protected final void removeTrackingListener(int listenerId) -
removeTrackingListenerAsync
-
map
-
getSubscribeService
-