Interface CPMap<K,V>

Type Parameters:
K - Key
V - Value
All Superinterfaces:
DistributedObject

public interface CPMap<K,V> extends DistributedObject
CPMap is a key-value store within CP. It can be accessed via CPSubsystem.getMap(String).

A CPMap must be able to fit within the member's host RAM. A CPMap is not partitioned like an IMap.

Since:
5.4
  • Method Details

    • put

      V put(@Nonnull K key, @Nonnull V value)
      Associates key with value.

      See set(K, V) for a more optimal solution when the previous value of @{code key} is not relevant.

      Parameters:
      key - non-null key of the entry
      value - non-null value of the entry
      Returns:
      null if key had no previous mapping, otherwise the previous value associated with key
      Throws:
      NullPointerException - when key or value is null
    • putIfAbsent

      V putIfAbsent(@Nonnull K key, @Nonnull V value)
      Associates key with value only if key is not present.
      Parameters:
      key - non-null key of the entry
      value - non-null value of the entry
      Returns:
      null if key had no previous mapping, otherwise the value associated with key
      Throws:
      NullPointerException - when key or value is null
    • set

      void set(@Nonnull K key, @Nonnull V value)
      Associates key with value.

      This method should be preferred over put(K, V) as it has a smaller network footprint due to the previous value associated with key not being transmitted. Use put(K, V) only when the previous value of key is required.

      Parameters:
      key - non-null key of the entry
      value - non-null value of the entry
      Throws:
      NullPointerException - when key or value is null
    • remove

      V remove(@Nonnull K key)
      Removes key if present.
      Parameters:
      key - non-null key of the key-value entry to remove
      Returns:
      null if key was not present, otherwise the value associated with key
      Throws:
      NullPointerException - when key is null
    • delete

      void delete(@Nonnull K key)
      Removes key if present.
      Parameters:
      key - non-null key of the key-value entry to remove
      Throws:
      NullPointerException - when key is null
    • compareAndSet

      boolean compareAndSet(@Nonnull K key, @Nonnull V expectedValue, @Nonnull V newValue)
      Atomically sets key to newValue if the current value for key is equal-to expectedValue.
      Parameters:
      key - non-null key of the entry
      expectedValue - non-null expected value associated with key
      newValue - non-null new value to associate with key
      Returns:
      true if key was associated with newValue, otherwise false
      Throws:
      NullPointerException - when key, expectedValue or newValue is null
    • get

      V get(@Nonnull K key)
      Gets the value associated with key
      Parameters:
      key - non-null key of the entry
      Returns:
      null if key had no association, otherwise the value associated with key
      Throws:
      NullPointerException - when key is null