Class MappedContainer<K>

java.lang.Object
org.rostore.client.MappedContainer<K>
Type Parameters:
K - the type of the key

public class MappedContainer<K> extends Object
Encapsulates access to the container that uses specific serializer / deserializer.

To create mapped container use RoStoreClient.getMappedContainer(String, Mapper)

  • Constructor Details

  • Method Details

    • remove

      public void remove()
    • create

      public void create(ContainerMeta containerMeta)
      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 operation
      updateFunction - function to update the value
      keyExpirationUpdateFunction - function to change the expiration TTL
      Returns:
      an updated key-value
    • update

      public <V> VersionedObject<K,V> update(VersionedObject<K,V> original, Function<V,V> updateFunction)
      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 operation
      updateFunction - function to update the value
      Returns:
      an updated key-value
    • post

      public <V> VersionedObject<K,V> post(VersionedObject<K,V> versionedObject)
      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 functions
      options - the options to specify the behaviour of the operation in different conditions
      Returns:
      the versionedObject as it comes from the remote
    • removeKey

      public boolean removeKey(K key)
      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

      public boolean removeKey(K key, long version)
      Remove a key from the storage

      The 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

      public boolean removeKey(K key, long version, EnumSet<RecordOption> options)
      Remove a key from the storage

      The 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

      public String getName()
      Returns:
      the name of the container
    • get

      public <V> VersionedObject<K,V> get(K key, Class<V> valueClass)
      Retrieves the object from the storage
      Type Parameters:
      V - the type of the value object
      Parameters:
      key - the key object
      valueClass - the class of the value object
      Returns:
      the key-value pair with metadata like TTL, version, and other