StateViewWriter

Writes the states of one aggregate type into its cache at their versions, the owner's writes after each commit: CoCache writes each only over an older version (SuspendingVersionedCache.putIfNewer), atomically, so a commit delivered again, a replay, or an old owner beside the new one never takes the cache back. A deleted aggregate is a tombstone at its version (SuspendingVersionedCache.invalidateIfNewer), which reads as absent and which no older state undoes. A reader's fill in flight holds the key's lease, which the write takes over: the fill is refused.

Each write lives for ttl when given, else for the cache's lifetime (its ttl), the tombstone too.

Functions

Link copied to clipboard
suspend fun delete(key: StateKey, version: Int): Boolean

Writes the tombstone of key, deleted at version: true when written, false when the cache holds a later one.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
suspend fun write(key: StateKey, view: V, version: Int): Boolean

Writes view under key at version: true when written, false when the cache holds that version or a later.