Interface TimeoutMap<K,V>

All Superinterfaces:
AutoCloseable, Service

public interface TimeoutMap<K,V> extends Service
Represents a map of values which timeout after a period of inactivity.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Assign the (singular) TimeoutMap.Listener
    get(K key)
    Looks up the value in the map by the given key.
    put(K key, V value, long timeoutMillis)
    Adds the key value pair into the map such that some time after the given timeout the entry will be evicted
    putIfAbsent(K key, V value, long timeoutMillis)
    Adds the key value pair into the map if the specified key is not already associated with a value such that some time after the given timeout the entry will be evicted.
    remove(K key)
    Removes the object with the given key
    int
    Returns the size of the map

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop
  • Method Details

    • get

      V get(K key)
      Looks up the value in the map by the given key.
      Parameters:
      key - the key of the value to search for
      Returns:
      the value for the given key or null if it is not present (or has timed out)
    • size

      int size()
      Returns the size of the map
      Returns:
      the size
    • put

      V put(K key, V value, long timeoutMillis)
      Adds the key value pair into the map such that some time after the given timeout the entry will be evicted
      Parameters:
      key - the key
      value - the value
      timeoutMillis - timeout in millis
      Returns:
      the previous value associated with key, or null if there was no mapping for key.
    • putIfAbsent

      V putIfAbsent(K key, V value, long timeoutMillis)
      Adds the key value pair into the map if the specified key is not already associated with a value such that some time after the given timeout the entry will be evicted. Expiry time of an existing mapping is left unchanged.
      Parameters:
      key - the key
      value - the value
      timeoutMillis - timeout in millis
      Returns:
      the value associated with key, or null if there was no mapping for key.
    • remove

      V remove(K key)
      Removes the object with the given key
      Parameters:
      key - key for the object to remove
      Returns:
      the value for the given key or null if it is not present (or has timed out)
    • addListener

      void addListener(TimeoutMap.Listener<K,V> listener)
      Assign the (singular) TimeoutMap.Listener
      Parameters:
      listener - the new listener