V
- value typepublic class RedissonBucket<V> extends RedissonObject implements RBucket<V>
codec, commandExecutor, name
Constructor and Description |
---|
RedissonBucket(Codec codec,
CommandAsyncExecutor connectionManager,
String name) |
RedissonBucket(CommandAsyncExecutor connectionManager,
String name) |
Modifier and Type | Method and Description |
---|---|
int |
addListener(ObjectListener listener)
Adds object event listener
|
RFuture<Integer> |
addListenerAsync(ObjectListener listener)
Adds object event listener
|
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) |
boolean |
compareAndSet(V expect,
V update)
Atomically sets the value to the given updated value
only if serialized state of the current value equals
to serialized state of the expected value.
|
RFuture<Boolean> |
compareAndSetAsync(V expect,
V update)
Atomically sets the value to the given updated value
only if serialized state of the current value equals
to serialized state of the expected value.
|
boolean |
expire(Instant instant)
Set an expire date for object.
|
boolean |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object.
|
RFuture<Boolean> |
expireAsync(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) |
boolean |
expireAt(Date timestamp)
Use
RExpirable.expire(Instant) instead |
boolean |
expireAt(long timestamp)
Use
RExpirable.expire(Instant) instead |
RFuture<Boolean> |
expireAtAsync(Date timestamp)
Use
RExpirableAsync.expireAsync(Instant) instead |
RFuture<Boolean> |
expireAtAsync(long timestamp)
Use
RExpirableAsync.expireAsync(Instant) instead |
protected RFuture<Boolean> |
expireAtAsync(long timestamp,
String... keys) |
V |
get()
Retrieves element stored in the holder.
|
V |
getAndDelete()
Retrieves element in the holder and removes it.
|
RFuture<V> |
getAndDeleteAsync()
Retrieves element in the holder and removes it.
|
V |
getAndSet(V newValue)
Retrieves current element in the holder and replaces it with
newValue . |
V |
getAndSet(V value,
long timeToLive,
TimeUnit timeUnit)
Retrieves current element in the holder and replaces it with
newValue with defined timeToLive interval. |
RFuture<V> |
getAndSetAsync(V newValue)
Retrieves current element in the holder and replaces it with
newValue . |
RFuture<V> |
getAndSetAsync(V value,
long timeToLive,
TimeUnit timeUnit)
Retrieves current element in the holder and replaces it with
newValue with defined timeToLive interval. |
RFuture<V> |
getAsync()
Retrieves element stored in the holder.
|
long |
remainTimeToLive()
Remaining time to live of Redisson object that has a timeout
|
RFuture<Long> |
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeout
|
void |
removeListener(int listenerId)
Removes object event listener
|
RFuture<Void> |
removeListenerAsync(int listenerId)
Removes object event listener
|
void |
set(V value)
Stores element into the holder.
|
void |
set(V value,
long timeToLive,
TimeUnit timeUnit)
Stores element into the holder with defined
timeToLive interval. |
void |
setAndKeepTTL(V value)
Set value and keep existing TTL.
|
RFuture<Void> |
setAndKeepTTLAsync(V value)
Set value and keep existing TTL.
|
RFuture<Void> |
setAsync(V value)
Stores element into the holder.
|
RFuture<Void> |
setAsync(V value,
long timeToLive,
TimeUnit timeUnit)
Stores element into the holder with defined
timeToLive interval. |
boolean |
setIfExists(V value)
Sets value only if it's already exists.
|
boolean |
setIfExists(V value,
long timeToLive,
TimeUnit timeUnit)
Sets value only if it's already exists.
|
RFuture<Boolean> |
setIfExistsAsync(V value)
Sets value only if it's already exists.
|
RFuture<Boolean> |
setIfExistsAsync(V value,
long timeToLive,
TimeUnit timeUnit)
Sets value only if it's already exists.
|
long |
size()
Returns size of object in bytes.
|
RFuture<Long> |
sizeAsync()
Returns size of object in bytes
|
boolean |
trySet(V value)
Tries to set element atomically into empty holder.
|
boolean |
trySet(V value,
long timeToLive,
TimeUnit timeUnit)
Tries to set element atomically into empty holder with defined
timeToLive interval. |
RFuture<Boolean> |
trySetAsync(V value)
Tries to set element atomically into empty holder.
|
RFuture<Boolean> |
trySetAsync(V value,
long timeToLive,
TimeUnit timeUnit)
Tries to set element atomically into empty holder with defined
timeToLive interval. |
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
public RedissonBucket(CommandAsyncExecutor connectionManager, String name)
public RedissonBucket(Codec codec, CommandAsyncExecutor connectionManager, String name)
public boolean compareAndSet(V expect, V update)
RBucket
compareAndSet
in interface RBucket<V>
expect
- the expected valueupdate
- the new valuetrue
if successful; or false
if the actual value
was not equal to the expected value.public RFuture<Boolean> compareAndSetAsync(V expect, V update)
RBucketAsync
compareAndSetAsync
in interface RBucketAsync<V>
expect
- the expected valueupdate
- the new valuetrue
if successful; or false
if the actual value
was not equal to the expected value.public V getAndSet(V newValue)
RBucket
newValue
.public RFuture<V> getAndSetAsync(V newValue)
RBucketAsync
newValue
.getAndSetAsync
in interface RBucketAsync<V>
newValue
- - value to setpublic V get()
RBucket
public RFuture<V> getAsync()
RBucketAsync
getAsync
in interface RBucketAsync<V>
public V getAndDelete()
RBucket
getAndDelete
in interface RBucket<V>
public RFuture<V> getAndDeleteAsync()
RBucketAsync
getAndDeleteAsync
in interface RBucketAsync<V>
public long size()
RBucket
public RFuture<Long> sizeAsync()
RBucketAsync
sizeAsync
in interface RBucketAsync<V>
public void set(V value)
RBucket
public RFuture<Void> setAsync(V value)
RBucketAsync
setAsync
in interface RBucketAsync<V>
value
- - value to setpublic void set(V value, long timeToLive, TimeUnit timeUnit)
RBucket
timeToLive
interval.public RFuture<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit)
RBucketAsync
timeToLive
interval.setAsync
in interface RBucketAsync<V>
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervalpublic RFuture<Boolean> trySetAsync(V value)
RBucketAsync
trySetAsync
in interface RBucketAsync<V>
value
- - value to settrue
if successful, or false
if
element was already setpublic RFuture<Boolean> trySetAsync(V value, long timeToLive, TimeUnit timeUnit)
RBucketAsync
timeToLive
interval.trySetAsync
in interface RBucketAsync<V>
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervaltrue
if successful, or false
if
element was already setpublic boolean trySet(V value, long timeToLive, TimeUnit timeUnit)
RBucket
timeToLive
interval.public boolean trySet(V value)
RBucket
public boolean setIfExists(V value)
RBucket
setIfExists
in interface RBucket<V>
value
- - value to settrue
if successful, or false
if
element wasn't setpublic RFuture<Boolean> setIfExistsAsync(V value)
RBucketAsync
setIfExistsAsync
in interface RBucketAsync<V>
value
- - value to settrue
if successful, or false
if
element wasn't setpublic void setAndKeepTTL(V value)
RBucket
Requires Redis 6.0.0 and higher.
setAndKeepTTL
in interface RBucket<V>
value
- - value to setpublic RFuture<Void> setAndKeepTTLAsync(V value)
RBucketAsync
Requires Redis 6.0.0 and higher.
setAndKeepTTLAsync
in interface RBucketAsync<V>
value
- - value to setpublic boolean setIfExists(V value, long timeToLive, TimeUnit timeUnit)
RBucket
setIfExists
in interface RBucket<V>
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervaltrue
if successful, or false
if
element wasn't setpublic RFuture<Boolean> setIfExistsAsync(V value, long timeToLive, TimeUnit timeUnit)
RBucketAsync
setIfExistsAsync
in interface RBucketAsync<V>
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervaltrue
if successful, or false
if
element wasn't setpublic RFuture<V> getAndSetAsync(V value, long timeToLive, TimeUnit timeUnit)
RBucketAsync
newValue
with defined timeToLive
interval.getAndSetAsync
in interface RBucketAsync<V>
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live intervalpublic V getAndSet(V value, long timeToLive, TimeUnit timeUnit)
RBucket
newValue
with defined timeToLive
interval.public int addListener(ObjectListener listener)
RObject
addListener
in interface RBucket<V>
addListener
in interface RObject
addListener
in class RedissonObject
listener
- - object event listenerExpiredObjectListener
,
DeletedObjectListener
public RFuture<Integer> addListenerAsync(ObjectListener listener)
RObjectAsync
addListenerAsync
in interface RBucketAsync<V>
addListenerAsync
in interface RObjectAsync
addListenerAsync
in class RedissonObject
listener
- - object event listenerExpiredObjectListener
,
DeletedObjectListener
public void removeListener(int listenerId)
RObject
removeListener
in interface RObject
removeListener
in class RedissonObject
listenerId
- - listener idpublic RFuture<Void> removeListenerAsync(int listenerId)
RObjectAsync
removeListenerAsync
in interface RObjectAsync
removeListenerAsync
in class RedissonObject
listenerId
- - listener idpublic boolean expire(long timeToLive, TimeUnit timeUnit)
RExpirable
expire
in interface RExpirable
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
RExpirableAsync
expireAsync
in interface RExpirableAsync
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic boolean expireAt(long timestamp)
RExpirable
RExpirable.expire(Instant)
insteadexpireAt
in interface RExpirable
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(long timestamp)
RExpirableAsync
RExpirableAsync.expireAsync(Instant)
insteadexpireAtAsync
in interface RExpirableAsync
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic boolean expire(Instant instant)
RExpirable
expire
in interface RExpirable
instant
- - expire datetrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAsync(Instant instant)
RExpirableAsync
expireAsync
in interface RExpirableAsync
instant
- - expire datetrue
if the timeout was set and false
if notpublic boolean expireAt(Date timestamp)
RExpirable
RExpirable.expire(Instant)
insteadexpireAt
in interface RExpirable
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(Date timestamp)
RExpirableAsync
RExpirableAsync.expireAsync(Instant)
insteadexpireAtAsync
in interface RExpirableAsync
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic boolean clearExpire()
RExpirable
clearExpire
in interface RExpirable
true
if timeout was removed
false
if object does not exist or does not have an associated timeoutpublic RFuture<Boolean> clearExpireAsync()
RExpirableAsync
clearExpireAsync
in interface RExpirableAsync
true
if the timeout was cleared and false
if notpublic long remainTimeToLive()
RExpirable
remainTimeToLive
in interface RExpirable
public RFuture<Long> remainTimeToLiveAsync()
RExpirableAsync
remainTimeToLiveAsync
in interface RExpirableAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
Copyright © 2014–2021 Redisson. All rights reserved.