Skip to main content
S2 is designed to accommodate both infinite accumulation of data, and time-bounded retention. You can use a stream as the long-term source of truth for your data, or as a momentary durable buffer on the way to somewhere else.

Age-based retention

A retention policy can be configured on a stream, and S2 will automatically delete records that are older than the configured threshold. This can be set when creating a stream or by reconfiguring an existing one.
Records may stay visible for a brief period after their retention window expires, typically on the order of minutes.

Explicit trimming

For more fine-grained control, you can explicitly trim a stream up to a specific sequence number. All records before the trim point will be removed.
s2 trim s2://my-basin/my-stream 1000
Trimming is eventually consistent — trimmed records may be visible for a brief period. The effective trim point will be max(existing_trim_point, min(provided_trim_point, current_tail)), so you can’t trim past the end of the stream, and you can’t move the trim point backwards.
Trimming is also available via the SDKs or by appending the trim command record.

See also