Interface LookupCache<K,V>

All Known Implementing Classes:
LRUMap

public interface LookupCache<K,V>
An interface describing the required API for the Jackson-databind Type cache.

Note that while interface itself does not specify synchronization requirements for implementations, specific use cases do. Typically implementations are expected to be thread-safe, that is, to handle synchronization.

Since:
2.12 (for forwards-compatiblity with 3.0)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Method for removing all contents this cache has.
    default void
    contents(BiConsumer<K,V> consumer)
    Method to apply operation on cache contents without exposing them.
    default LookupCache<K,V>
    Method needed for creating clones but without contents.
    get(Object key)
    NOTE: key is of type Object only to retain binary backwards-compatibility
    put(K key, V value)
     
    putIfAbsent(K key, V value)
     
    int
     
  • Method Details

    • contents

      default void contents(BiConsumer<K,V> consumer)
      Method to apply operation on cache contents without exposing them.

      Default implementation throws UnsupportedOperationException. Implementations are required to override this method.

      Parameters:
      consumer - Operation to apply on cache contents.
      Throws:
      UnsupportedOperationException - if implementation does not override this method.
      Since:
      2.16
    • emptyCopy

      default LookupCache<K,V> emptyCopy()
      Method needed for creating clones but without contents.

      Default implementation throws UnsupportedOperationException. Implementations are required to override this method.

      Throws:
      UnsupportedOperationException - if implementation does not override this method.
      Since:
      2.16
    • size

      int size()
      Returns:
      Number of entries currently in cache: may be approximate, only to be used for diagnostics, metrics reporting
    • get

      V get(Object key)
      NOTE: key is of type Object only to retain binary backwards-compatibility
      Returns:
      value associated with key (can return null)
    • put

      V put(K key, V value)
    • putIfAbsent

      V putIfAbsent(K key, V value)
    • clear

      void clear()
      Method for removing all contents this cache has.