RedisStreamRetentionOptions

data class RedisStreamRetentionOptions(val maxLength: Long? = null, val maxAge: Duration? = null, val approximate: Boolean = true, val consumerIdleTimeout: Duration? = DEFAULT_CONSUMER_IDLE_TIMEOUT)

What the Redis stream bus keeps: stream entries and consumers.

Entries. Trimming is off by default: an entry stays until it is deleted by hand, so a consumer group that falls behind, or a new group that replays from the start, still finds it. Set at most one of:

  • maxLength: every XADD trims the stream to about this many entries (MAXLEN ~);

  • maxAge: every XADD trims entries older than this (MINID ~, from the sender's clock). It must be at least MIN_MAX_AGE and far larger than the clock skew between senders: a sender whose clock runs ahead trims younger entries. Trimming applies to every consumer group: an entry a lagging group has not read yet is lost to it, so size the limit to the slowest group's worst lag. With approximate (the default) Redis trims whole macro nodes, which is much cheaper; the stream may hold a few more entries than the limit. Trimming needs Redis 7.0 or later: it can remove entries still pending for a consumer, and before 7.0 claiming such an entry (XCLAIM) keeps failing.

Consumers. Each subscription start joins its group under a new consumer name, so a restarted node leaves its old consumer behind. When a receiver starts, it deletes (XGROUP DELCONSUMER) the consumers of its group that have no pending entries and have been idle for at least consumerIdleTimeout: deleting a consumer with nothing pending loses nothing, and a live consumer that is deleted is re-created by its next read. null keeps every consumer.

Constructors

Link copied to clipboard
constructor(maxLength: Long? = null, maxAge: Duration? = null, approximate: Boolean = true, consumerIdleTimeout: Duration? = DEFAULT_CONSUMER_IDLE_TIMEOUT)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether XADD trims the stream.