Package org.redisson.reactive
Class RedissonReadWriteLockReactive
- java.lang.Object
-
- org.redisson.reactive.RedissonReadWriteLockReactive
-
- All Implemented Interfaces:
RExpirableReactive
,RObjectReactive
,RReadWriteLockReactive
public class RedissonReadWriteLockReactive extends Object implements RReadWriteLockReactive
- Author:
- Nikita Koksharov
-
-
Constructor Summary
Constructors Constructor Description RedissonReadWriteLockReactive(CommandReactiveExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactivestreams.Publisher<Boolean>
clearExpire()
Clear an expire timeout or expire date for object in mode.org.reactivestreams.Publisher<Void>
copy(String host, int port, int database, long timeout)
Copy object from source Redis instance to destination Redis instanceorg.reactivestreams.Publisher<Boolean>
delete()
Delete object in modeorg.reactivestreams.Publisher<byte[]>
dump()
Returns dump of objectprotected io.netty.buffer.ByteBuf
encode(Object value)
protected void
encode(Collection<Object> params, Collection<?> values)
protected io.netty.buffer.ByteBuf
encodeMapKey(Object value)
protected io.netty.buffer.ByteBuf
encodeMapValue(Object value)
org.reactivestreams.Publisher<Boolean>
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object in mode.org.reactivestreams.Publisher<Boolean>
expireAt(long timestamp)
Set an expire date for object in mode.org.reactivestreams.Publisher<Boolean>
expireAt(Date timestamp)
Set an expire date for object in mode.Codec
getCodec()
String
getName()
org.reactivestreams.Publisher<Boolean>
isExists()
Check object existenceorg.reactivestreams.Publisher<Void>
migrate(String host, int port, int database, long timeout)
Transfer a object from a source Redis instance to a destination Redis instance in modeorg.reactivestreams.Publisher<Boolean>
move(int database)
Move object to another database in modeprotected <V> reactor.rx.Stream<V>
newSucceeded(V result)
<R> org.reactivestreams.Publisher<R>
reactive(reactor.fn.Supplier<RFuture<R>> supplier)
RLockReactive
readLock()
Returns the lock used for reading.org.reactivestreams.Publisher<Long>
remainTimeToLive()
Get remaining time to live of object in milliseconds.org.reactivestreams.Publisher<Void>
rename(String newName)
Rename current object key tonewName
in modeorg.reactivestreams.Publisher<Boolean>
renamenx(String newName)
Rename current object key tonewName
in mode only if new key is not existsorg.reactivestreams.Publisher<Void>
restore(byte[] state)
Restores object using its state returned byRObjectReactive.dump()
method.org.reactivestreams.Publisher<Void>
restore(byte[] state, long timeToLive, TimeUnit timeUnit)
Restores object using its state returned byRObjectReactive.dump()
method and set time to live for it.org.reactivestreams.Publisher<Void>
restoreAndReplace(byte[] state)
Restores and replaces object if it already exists.org.reactivestreams.Publisher<Void>
restoreAndReplace(byte[] state, long timeToLive, TimeUnit timeUnit)
Restores and replaces object if it already exists and set time to live for it.org.reactivestreams.Publisher<Boolean>
touch()
Update the last access time of an object.org.reactivestreams.Publisher<Boolean>
unlink()
Delete the objects.RLockReactive
writeLock()
Returns the lock used for writing.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.redisson.api.RExpirableReactive
clearExpire, expire, expireAt, expireAt, remainTimeToLive
-
-
-
-
Constructor Detail
-
RedissonReadWriteLockReactive
public RedissonReadWriteLockReactive(CommandReactiveExecutor commandExecutor, String name)
-
-
Method Detail
-
readLock
public RLockReactive readLock()
Description copied from interface:RReadWriteLockReactive
Returns the lock used for reading.- Specified by:
readLock
in interfaceRReadWriteLockReactive
- Returns:
- the lock used for reading
-
writeLock
public RLockReactive writeLock()
Description copied from interface:RReadWriteLockReactive
Returns the lock used for writing.- Specified by:
writeLock
in interfaceRReadWriteLockReactive
- Returns:
- the lock used for writing
-
expire
public org.reactivestreams.Publisher<Boolean> expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableReactive
Set a timeout for object in mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirableReactive
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public org.reactivestreams.Publisher<Boolean> expireAt(long timestamp)
Description copied from interface:RExpirableReactive
Set an expire date for object in mode. When expire date comes the key will automatically be deleted.- Specified by:
expireAt
in interfaceRExpirableReactive
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public org.reactivestreams.Publisher<Boolean> expireAt(Date timestamp)
Description copied from interface:RExpirableReactive
Set an expire date for object in mode. When expire date comes the key will automatically be deleted.- Specified by:
expireAt
in interfaceRExpirableReactive
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
clearExpire
public org.reactivestreams.Publisher<Boolean> clearExpire()
Description copied from interface:RExpirableReactive
Clear an expire timeout or expire date for object in mode. Object will not be deleted.- Specified by:
clearExpire
in interfaceRExpirableReactive
- Returns:
true
if the timeout was cleared andfalse
if not
-
remainTimeToLive
public org.reactivestreams.Publisher<Long> remainTimeToLive()
Description copied from interface:RExpirableReactive
Get remaining time to live of object in milliseconds.- Specified by:
remainTimeToLive
in interfaceRExpirableReactive
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
reactive
public <R> org.reactivestreams.Publisher<R> reactive(reactor.fn.Supplier<RFuture<R>> supplier)
-
newSucceeded
protected <V> reactor.rx.Stream<V> newSucceeded(V result)
-
getName
public String getName()
- Specified by:
getName
in interfaceRObjectReactive
-
getCodec
public Codec getCodec()
- Specified by:
getCodec
in interfaceRObjectReactive
-
encode
protected void encode(Collection<Object> params, Collection<?> values)
-
encode
protected io.netty.buffer.ByteBuf encode(Object value)
-
encodeMapKey
protected io.netty.buffer.ByteBuf encodeMapKey(Object value)
-
encodeMapValue
protected io.netty.buffer.ByteBuf encodeMapValue(Object value)
-
restore
public org.reactivestreams.Publisher<Void> restore(byte[] state)
Description copied from interface:RObjectReactive
Restores object using its state returned byRObjectReactive.dump()
method.- Specified by:
restore
in interfaceRObjectReactive
- Parameters:
state
- - state of object- Returns:
- void
-
restore
public org.reactivestreams.Publisher<Void> restore(byte[] state, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RObjectReactive
Restores object using its state returned byRObjectReactive.dump()
method and set time to live for it.- Specified by:
restore
in interfaceRObjectReactive
- Parameters:
state
- - state of objecttimeToLive
- - time to live of the objecttimeUnit
- - time unit- Returns:
- void
-
restoreAndReplace
public org.reactivestreams.Publisher<Void> restoreAndReplace(byte[] state)
Description copied from interface:RObjectReactive
Restores and replaces object if it already exists.- Specified by:
restoreAndReplace
in interfaceRObjectReactive
- Parameters:
state
- - state of the object- Returns:
- void
-
restoreAndReplace
public org.reactivestreams.Publisher<Void> restoreAndReplace(byte[] state, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RObjectReactive
Restores and replaces object if it already exists and set time to live for it.- Specified by:
restoreAndReplace
in interfaceRObjectReactive
- Parameters:
state
- - state of the objecttimeToLive
- - time to live of the objecttimeUnit
- - time unit- Returns:
- void
-
dump
public org.reactivestreams.Publisher<byte[]> dump()
Description copied from interface:RObjectReactive
Returns dump of object- Specified by:
dump
in interfaceRObjectReactive
- Returns:
- dump
-
touch
public org.reactivestreams.Publisher<Boolean> touch()
Description copied from interface:RObjectReactive
Update the last access time of an object.- Specified by:
touch
in interfaceRObjectReactive
- Returns:
true
if object was touched elsefalse
-
unlink
public org.reactivestreams.Publisher<Boolean> unlink()
Description copied from interface:RObjectReactive
Delete the objects. Actual removal will happen later asynchronously.Requires Redis 4.0+
- Specified by:
unlink
in interfaceRObjectReactive
- Returns:
true
if it was exist and deleted elsefalse
-
copy
public org.reactivestreams.Publisher<Void> copy(String host, int port, int database, long timeout)
Description copied from interface:RObjectReactive
Copy object from source Redis instance to destination Redis instance- Specified by:
copy
in interfaceRObjectReactive
- 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
-
rename
public org.reactivestreams.Publisher<Void> rename(String newName)
Description copied from interface:RObjectReactive
Rename current object key tonewName
in mode- Specified by:
rename
in interfaceRObjectReactive
- Parameters:
newName
- - new name of object- Returns:
- void
-
migrate
public org.reactivestreams.Publisher<Void> migrate(String host, int port, int database, long timeout)
Description copied from interface:RObjectReactive
Transfer a object from a source Redis instance to a destination Redis instance in mode- Specified by:
migrate
in interfaceRObjectReactive
- 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 org.reactivestreams.Publisher<Boolean> move(int database)
Description copied from interface:RObjectReactive
Move object to another database in mode- Specified by:
move
in interfaceRObjectReactive
- Parameters:
database
- - number of Redis database- Returns:
true
if key was movedfalse
if not
-
renamenx
public org.reactivestreams.Publisher<Boolean> renamenx(String newName)
Description copied from interface:RObjectReactive
Rename current object key tonewName
in mode only if new key is not exists- Specified by:
renamenx
in interfaceRObjectReactive
- Parameters:
newName
- - new name of object- Returns:
true
if object has been renamed successfully andfalse
otherwise
-
delete
public org.reactivestreams.Publisher<Boolean> delete()
Description copied from interface:RObjectReactive
Delete object in mode- Specified by:
delete
in interfaceRObjectReactive
- Returns:
true
if object was deletedfalse
if not
-
isExists
public org.reactivestreams.Publisher<Boolean> isExists()
Description copied from interface:RObjectReactive
Check object existence- Specified by:
isExists
in interfaceRObjectReactive
- Returns:
true
if object exists andfalse
otherwise
-
-