Package org.apache.storm.state

## Interface KeyValueState<K,​V>

- All Superinterfaces:
    `Iterable<Map.Entry<K,​V>>`, `State`
  All Known Implementing Classes:
    `InMemoryKeyValueState`, `RedisKeyValueState`

      public interface KeyValueState<K,​V>
      extends State, Iterable<Map.Entry<K,​V>>

  A state that supports key-value mappings.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `V` | `delete​(K key)` | Deletes the value mapped to the key, if there is any.
    `V` | `get​(K key)` | Returns the value mapped to the key.
    `V` | `get​(K key, V defaultValue)` | Returns the value mapped to the key or defaultValue if no mapping is found.
    `void` | `put​(K key, V value)` | Maps the value with the key.

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, iterator, spliterator`

    - ### Methods inherited from interface org.apache.storm.state.State

      `commit, commit, prepareCommit, rollback`

- - ### Method Detail

    - #### put

          void put​(K key,
                   V value)

      Maps the value with the key.
      Parameters:
        `key` - the key
        `value` - the value

    - #### get

          V get​(K key)

      Returns the value mapped to the key.
      Parameters:
        `key` - the key
      Returns:
        the value or null if no mapping is found

    - #### get

          V get​(K key,
                V defaultValue)

      Returns the value mapped to the key or defaultValue if no mapping is found.
      Parameters:
        `key` - the key
        `defaultValue` - the value to return if no mapping is found
      Returns:
        the value or defaultValue if no mapping is found

    - #### delete

          V delete​(K key)

      Deletes the value mapped to the key, if there is any.
      Parameters:
        `key` - the key