Interface DocHandlerCache

All Known Implementing Classes:
ClusterDocHandlerCache
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface DocHandlerCache

A key/value cache made available to document handlers for results that are expensive or costly to obtain more than once for the same input (e.g., a call to a paid external API). The importer itself does not implement one: whatever runs it (a crawler, the command-line launcher, a test) may supply one via DocHandlerContext, so it can back it with whatever storage makes sense there — a crawler backs it with its own persistent, cluster- aware store, at no extra cost to a handler that uses it.

A handler is never left checking for null: when nothing is supplied, DocHandlerContext falls back to NOOP, which always calls the DocHandlerCache.Loader and never remembers the result.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Computes a value to be cached, for whichever key was not already in the cache.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final DocHandlerCache
    A cache that holds nothing: every lookup is a miss, so the DocHandlerCache.Loader always runs.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value previously cached for key, or computes it with loader, caches it, then returns it.
  • Field Details

  • Method Details

    • computeIfAbsent

      String computeIfAbsent(String key, DocHandlerCache.Loader loader) throws IOException
      Returns the value previously cached for key, or computes it with loader, caches it, then returns it.
      Parameters:
      key - cache key
      loader - supplies the value when not already cached
      Returns:
      the cached or freshly computed value
      Throws:
      IOException - if the loader fails to compute a value