org.apache.lucene.search

## Interface QueryCachingPolicy

- All Known Implementing Classes:
    QueryCachingPolicy.CacheOnLargeSegments, UsageTrackingQueryCachingPolicy

      public interface QueryCachingPolicy

  A policy defining which filters should be cached. Implementations of this class must be thread-safe.
  See Also:
    `UsageTrackingQueryCachingPolicy`, `LRUQueryCache`
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `QueryCachingPolicy.CacheOnLargeSegments` A simple policy that only caches on the largest segments of an index.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static QueryCachingPolicy` | `ALWAYS_CACHE` A simple policy that caches all the provided filters on all segments.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `onUse(Query query)` Callback that is called every time that a cached filter is used.
    `boolean` | `shouldCache(Query query, LeafReaderContext context)` Whether the given `DocIdSet` should be cached on a given segment.

- - ### Field Detail

    - #### ALWAYS_CACHE

          static final QueryCachingPolicy ALWAYS_CACHE

      A simple policy that caches all the provided filters on all segments.

  - ### Method Detail

    - #### onUse

          void onUse(Query query)

      Callback that is called every time that a cached filter is used. This is typically useful if the policy wants to track usage statistics in order to make decisions.

    - #### shouldCache

          boolean shouldCache(Query query,
                            LeafReaderContext context)
                              throws IOException

      Whether the given `DocIdSet` should be cached on a given segment. This method will be called on each leaf context to know if the filter should be cached on this particular leaf. The filter cache will first attempt to load a `DocIdSet` from the cache. If it is not cached yet and this method returns `true` then a cache entry will be generated. Otherwise an uncached set will be returned.
      Throws:
        `IOException`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.