Package org.redisson.api
Interface RBucket<V>
-
- Type Parameters:
V
- - the type of object
- All Superinterfaces:
RBucketAsync<V>
,RExpirable
,RExpirableAsync
,RObject
,RObjectAsync
- All Known Subinterfaces:
RBinaryStream
- All Known Implementing Classes:
RedissonBinaryStream
,RedissonBucket
,RedissonTransactionalBucket
public interface RBucket<V> extends RExpirable, RBucketAsync<V>
Object holder. Max size of object is 512MB- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
addListener(ObjectListener listener)
Adds object event listenerboolean
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.V
get()
Retrieves element stored in the holder.V
getAndDelete()
Retrieves element in the holder and removes it.V
getAndSet(V newValue)
Retrieves current element in the holder and replaces it withnewValue
.V
getAndSet(V value, long timeToLive, TimeUnit timeUnit)
Retrieves current element in the holder and replaces it withnewValue
with definedtimeToLive
interval.void
set(V value)
Stores element into the holder.void
set(V value, long timeToLive, TimeUnit timeUnit)
Stores element into the holder with definedtimeToLive
interval.void
setAndKeepTTL(V value)
Set value and keep existing TTL.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.long
size()
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 definedtimeToLive
interval.-
Methods inherited from interface org.redisson.api.RBucketAsync
addListenerAsync, compareAndSetAsync, getAndDeleteAsync, getAndSetAsync, getAndSetAsync, getAsync, setAndKeepTTLAsync, setAsync, setAsync, setIfExistsAsync, setIfExistsAsync, sizeAsync, trySetAsync, trySetAsync
-
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.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
-
-
-
-
Method Detail
-
size
long size()
Returns size of object in bytes.- Returns:
- object size
-
get
V get()
Retrieves element stored in the holder.- Returns:
- element
-
getAndDelete
V getAndDelete()
Retrieves element in the holder and removes it.- Returns:
- element
-
trySet
boolean trySet(V value)
Tries to set element atomically into empty holder.- Parameters:
value
- - value to set- Returns:
true
if successful, orfalse
if element was already set
-
trySet
boolean trySet(V value, long timeToLive, TimeUnit timeUnit)
Tries to set element atomically into empty holder with definedtimeToLive
interval.- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval- Returns:
true
if successful, orfalse
if element was already set
-
setIfExists
boolean setIfExists(V value)
Sets value only if it's already exists.- Parameters:
value
- - value to set- Returns:
true
if successful, orfalse
if element wasn't set
-
setIfExists
boolean setIfExists(V value, long timeToLive, TimeUnit timeUnit)
Sets value only if it's already exists.- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval- Returns:
true
if successful, orfalse
if element wasn't set
-
compareAndSet
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.- Parameters:
expect
- the expected valueupdate
- the new value- Returns:
true
if successful; orfalse
if the actual value was not equal to the expected value.
-
getAndSet
V getAndSet(V newValue)
Retrieves current element in the holder and replaces it withnewValue
.- Parameters:
newValue
- - value to set- Returns:
- previous value
-
getAndSet
V getAndSet(V value, long timeToLive, TimeUnit timeUnit)
Retrieves current element in the holder and replaces it withnewValue
with definedtimeToLive
interval.- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval- Returns:
- previous value
-
set
void set(V value)
Stores element into the holder.- Parameters:
value
- - value to set
-
set
void set(V value, long timeToLive, TimeUnit timeUnit)
Stores element into the holder with definedtimeToLive
interval.- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval
-
setAndKeepTTL
void setAndKeepTTL(V value)
Set value and keep existing TTL.Requires Redis 6.0.0 and higher.
- Parameters:
value
- - value to set
-
addListener
int addListener(ObjectListener listener)
Adds object event listener- Specified by:
addListener
in interfaceRObject
- Parameters:
listener
- - object event listener- Returns:
- listener id
- See Also:
ExpiredObjectListener
,DeletedObjectListener
,SetObjectListener
-
-