Interface LookupCache<K,V>

All Superinterfaces:
Snapshottable<LookupCache<K,V>>
All Known Implementing Classes:
SimpleLookupCache

public interface LookupCache<K,V> extends Snapshottable<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.

See Also:
  • 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.
    Method needed for creating clones but without contents.
    get(K key)
     
    put(K key, V value)
     
    putIfAbsent(K key, V value)
     
    int
     

    Methods inherited from interface tools.jackson.core.util.Snapshottable

    snapshot
  • 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.
    • emptyCopy

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

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

      V get(K key)
      Parameters:
      key -
      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.