SessionCacheConfig

data class SessionCacheConfig(val ttl: Duration = DEFAULT_TTL, val maxSessions: Int = DEFAULT_MAX_SESSIONS)

Configuration for the read cache of a BufferedSessionService.

The cache assumes this service makes every change to the sessions it caches: until an entry expires, a hit misses changes made elsewhere, such as app: and user: state another instance changed or a session the store deleted. A hit does not wait for buffered writes, so it can show events the store does not hold yet, or never will if their write fails, after which a read goes to the store. The sessions an unfiltered BufferedSessionService.getSession returns share their events and state values with the cache, and a hit can differ from what the store returns, such as in event order, event ids or fields the store does not keep.

Constructors

Link copied to clipboard
constructor(ttl: Duration = DEFAULT_TTL, maxSessions: Int = DEFAULT_MAX_SESSIONS)

Types

Link copied to clipboard
class Builder

Fluent builder for SessionCacheConfig, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The most sessions cached at once, 1024 by default; past it, the session read least recently is dropped.

Link copied to clipboard

How long a session stays cached after it is read from the store, 5 minutes by default; Duration.INFINITE disables expiry.

Functions

Link copied to clipboard

Returns a Builder initialized with this instance's properties, primarily for Java callers. Prefer it over copy from Java: copy takes every property positionally, so its signature changes whenever a property is added.

Link copied to clipboard

Returns ttl in whole milliseconds, or Long.MAX_VALUE if it never expires (its getter is mangled for Java).