Package net.thevpc.naru.api.model
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic NaruCachePlanViewallCacheable(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.cacheBreakpoints(int maxBreakpoints) Segment indices after which a marker should be placed, capped atmaxBreakpoints.booleanisCacheHit(int i) Whether segmentiis a continuation of the previously cached prefix and the caller marked it cacheable.mode()static NaruCachePlanViewnone()The plan used when a request carries no segmentation, or when the provider has no caching support.segments()The segments in emission order.
-
Method Details
-
segments
List<NaruContextSegment> segments()The segments in emission order. -
isCacheHit
boolean isCacheHit(int i) Whether segmentiis 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
Segment indices after which a marker should be placed, capped atmaxBreakpoints. May return fewer than the cap when fewer segments qualify; never returns more. -
mode
NaruCachingMode mode() -
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
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.
-