Interface SharedMap<K,​V>

  • Type Parameters:
    K - the type of keys maintained by this map.
    V - the type of values maintained by this map.

    public interface SharedMap<K,​V>
    Shared Map is similar to other Map, but its instances are shared across all applications and even cluster nodes. Due to distributed nature of Shared Map it is recommended to use only Standard Serializable Java classes as keys and values. Other types may not work as expected.

    WARNING: SharedMap has no guarantees for value mutability or immutability. Make sure you don't modify the values in-place.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void delete​(K key)
      Removes the mapping for the key from this map if it is present.
      V get​(K key)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      V modify​(K key, Function<V,​V> modifier)
      Equivalent of calling modify(Object, Function, int) modify(k, f, -1)}
      V modify​(K key, Function<V,​V> modifier, int ttlSeconds)
      Attempts to compute a mapping for the specified key and its current mapped value.
      void set​(K key, V value)
      Equivalent of calling set(Object, Object, int) set(k, v, -1)}
      void set​(K key, V value, int ttlSeconds)
      Puts an entry into this map with a given time to live (TTL).
    • Method Detail

      • get

        V get​(K key)
        Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped, or null if this map contains no mapping for the key
      • delete

        void delete​(K key)
        Removes the mapping for the key from this map if it is present.
        Parameters:
        key - the key whose associated value is to be removed
      • set

        void set​(K key,
                 V value)
        Equivalent of calling set(Object, Object, int) set(k, v, -1)}
        Parameters:
        key - key of the entry
        value - value of the entry
      • set

        void set​(K key,
                 V value,
                 int ttlSeconds)
        Puts an entry into this map with a given time to live (TTL). If value is null, the existing entry will be removed
        Parameters:
        key - key of the entry
        value - value of the entry
        ttlSeconds - maximum time to live in seconds for this entry to stay in the map. (0 means infinite, negative means map provider (for instance Hazelcast) default or infinite if map provider does not have own TTL setting)
      • modify

        V modify​(K key,
                 Function<V,​V> modifier)
        Equivalent of calling modify(Object, Function, int) modify(k, f, -1)}
        Parameters:
        key - key of the entry
        modifier - mapping function that accepts the existing mapped value (or null, if there is no associated mapping). The returned value replaces the existing mapped value for the specified key. If returned value is null then the value is removed from the map
        Returns:
        the new value to which the specified key is mapped, or null if this map no longer contains mapping for the key
      • modify

        V modify​(K key,
                 Function<V,​V> modifier,
                 int ttlSeconds)
        Attempts to compute a mapping for the specified key and its current mapped value. The mapping is done atomically with other modify calls.
        Parameters:
        key - key of the entry
        modifier - mapping function that accepts the existing mapped value (or null, if there is no associated mapping). The returned value replaces the existing mapped value for the specified key. If returned value is null then the value is removed from the map
        ttlSeconds - maximum time to live in seconds for this entry to stay in the map. (0 means infinite, negative means map provider (for instance Hazelcast) default or infinite if map provider does not have own TTL setting)
        Returns:
        the new value to which the specified key is mapped, or null if this map no longer contains mapping for the key