Interface NaruCachePlanView

All Known Implementing Classes:
NaruCachePlanView.None

public interface NaruCachePlanView
What a serializer needs to know to place cache markers, without knowing how NARU decides cache validity.

Kept in naru-api as a narrow view so serializers can be written against it while the invalidation logic stays in the model layer. It answers two questions only: which segments are still a cached prefix, and where should a marker go.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    A plan derived straight from a context with no prior baseline: used by serializers in tests and by callers that want markers on the first call.
    cacheBreakpoints(int maxBreakpoints)
    Segment indices after which a marker should be placed, capped at maxBreakpoints.
    boolean
    isCacheHit(int i)
    Whether segment i is a continuation of the previously cached prefix and the caller marked it cacheable.
     
    The plan used when a request carries no segmentation, or when the provider has no caching support.
    The segments in emission order.
  • Method Details

    • segments

      The segments in emission order.
    • isCacheHit

      boolean isCacheHit(int i)
      Whether segment i is a continuation of the previously cached prefix and the caller marked it cacheable. A segment past the divergence point is never a hit, whatever the caller claimed, because its position in the prefix changed.
    • cacheBreakpoints

      List<Integer> cacheBreakpoints(int maxBreakpoints)
      Segment indices after which a marker should be placed, capped at maxBreakpoints. May return fewer than the cap when fewer segments qualify; never returns more.
    • mode

    • none

      static NaruCachePlanView none()
      The plan used when a request carries no segmentation, or when the provider has no caching support. Everything is a miss, so a serializer that ignores it entirely produces the same body as before.
    • allCacheable

      static NaruCachePlanView allCacheable(NaruCacheableContext context)
      A plan derived straight from a context with no prior baseline: used by serializers in tests and by callers that want markers on the first call.