Class MappedContainer<K>
- Type Parameters:
K
- the type of the key
To create mapped container use RoStoreClient.getMappedContainer(String, Mapper)
-
Constructor Summary
ModifierConstructorDescriptionprotected
MappedContainer
(RoStoreClient roStoreClient, String name, Mapper mapper, KeySerializer<K> keySerializer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
create
(ContainerMeta containerMeta) Creates a new container<V> VersionedObject
<K, V> Retrieves the object from the storagegetName()
<V> VersionedObject
<K, V> post
(VersionedObject<K, V> versionedObject) Creates a new key-value pair.<V> VersionedObject
<K, V> post
(VersionedObject<K, V> versionedObject, EnumSet<RecordOption> options) Creates a new key-value pair.void
remove()
boolean
Remove a key from the storageboolean
Remove a key from the storageboolean
removeKey
(K key, long version, EnumSet<RecordOption> options) Remove a key from the storage<V> VersionedObject
<K, V> update
(VersionedObject<K, V> original, Function<V, V> updateFunction) Updates a versioned key-value pair.<V> VersionedObject
<K, V> update
(VersionedObject<K, V> original, Function<V, V> updateFunction, KeyExpirationUpdateFunction keyExpirationUpdateFunction) Updates a versioned key-value pair.
-
Constructor Details
-
MappedContainer
protected MappedContainer(RoStoreClient roStoreClient, String name, Mapper mapper, KeySerializer<K> keySerializer)
-
-
Method Details
-
remove
public void remove() -
create
Creates a new container- Parameters:
containerMeta
- container meta data
-
update
public <V> VersionedObject<K,V> update(VersionedObject<K, V> original, Function<V, V> updateFunction, KeyExpirationUpdateFunction keyExpirationUpdateFunction) Updates a versioned key-value pair.This operation is especially important for versioned key-values.
If the value has been changed on the remote end, this operation will detect it and reload the object, then the update function will again be applied. If the update of the key will fail again, because the remote object has changed in a meantime, the get operation will be repeated. Until it is successful, or a defined number of attempts has reached.
- Type Parameters:
V
- the type of the value- Parameters:
original
- the original key-value pair, obtained previously over the get or post operationupdateFunction
- function to update the valuekeyExpirationUpdateFunction
- function to change the expiration TTL- Returns:
- an updated key-value
-
update
Updates a versioned key-value pair.This operation is especially important for versioned key-values.
This is similar to
update(VersionedObject, Function, KeyExpirationUpdateFunction)
, but lacks the keyExpirationUpdateFunction, which just re-apply the expiration properties of the remote version of the object- Type Parameters:
V
- the type of the value- Parameters:
original
- the original key-value pair, obtained previously over the get or post operationupdateFunction
- function to update the value- Returns:
- an updated key-value
-
post
Creates a new key-value pair.- Type Parameters:
V
- the type of the value- Parameters:
versionedObject
- is created by one of the object's static functions- Returns:
- the versionedObject as it comes from the remote
-
post
public <V> VersionedObject<K,V> post(VersionedObject<K, V> versionedObject, EnumSet<RecordOption> options) Creates a new key-value pair.This variant of the post allows to set one or several
RecordOption
to modify the default behaviour of the post operation- Type Parameters:
V
- the type of the value- Parameters:
versionedObject
- is created by one of the object's static functionsoptions
- the options to specify the behaviour of the operation in different conditions- Returns:
- the versionedObject as it comes from the remote
-
removeKey
Remove a key from the storage- Parameters:
key
- the key to remove- Returns:
true
if object existed on the storage and has been successfully removed
-
removeKey
Remove a key from the storageThe operation will respect the version of the local object and will fail if the local version if outdated.
- Parameters:
key
- the key to remove- Returns:
true
if object existed on the storage and has been successfully removed
-
removeKey
Remove a key from the storageThe operation will respect the version of the local object and will fail if the local version if outdated.
A set options can be provided to modify the default behaviour of the operation.
- Parameters:
key
- the key to remove- Returns:
true
if object existed on the storage and has been successfully removed
-
getName
- Returns:
- the name of the container
-
get
Retrieves the object from the storage- Type Parameters:
V
- the type of the value object- Parameters:
key
- the key objectvalueClass
- the class of the value object- Returns:
- the key-value pair with metadata like TTL, version, and other
-