StreamReplay

How SemanticCache.getOrPutStreaming replays a cached answer on a hit.

A cache hit on a streaming path has to decide what a "stream" of an answer that is already written down even means, and the honest answers are few. This enum exists so the decision is made in the API, by the caller, rather than falling out of an implementation detail.

What is not here, and why

There is no option that reproduces the original timing. Doing it would mean recording how long each chunk took to arrive from the provider, figures that describe one model call, on one network, on one day, and then sleeping through them to serve an answer the cache already has in memory. That is a cache made deliberately slower in order to look like the thing it replaced, and the whole argument for this library is that it does not dress one measurement up as another. A hit is fast. Letting it look slow would be the pretence, not the honesty.

If a product genuinely needs a typewriter effect, that is a presentation decision and it belongs in the presentation layer, where it can be tuned, disabled and tested. It does not belong baked into a cache and paid for in stored bytes on every entry.

Entries

Link copied to clipboard

Emit the same chunks the provider produced, one after another, with no delay. The default.

Link copied to clipboard

Emit the whole answer as one element.

Properties

Link copied to clipboard

Returns a representation of an immutable list of all enum entries, in the order they're declared.

Link copied to clipboard
expect val name: String
Link copied to clipboard
expect val ordinal: Int

Functions

Link copied to clipboard

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Link copied to clipboard

Returns an array containing the constants of this enum type, in the order they're declared.