public Materialized<K, V, S> withRetention(final Duration retention) throws IllegalArgumentException {
        final String msgPrefix = prepareMillisCheckFailMsgPrefix(retention, "retention");
        final long retentionMs = validateMillisecondDuration(retention, msgPrefix);

        if (retentionMs < 0) {
            throw new IllegalArgumentException("Retention must not be negative.");
        }
        this.retention = retention;
        return this;
    }
Configure retention period for window and session stores. Ignored for key/value stores.

Overridden by pre-configured store suppliers
({@link Materialized#as(SessionBytesStoreSupplier)} or {@link Materialized#as(WindowBytesStoreSupplier)}).

Note that the retention period must be at least long enough to contain the windowed data's entire life cycle,
from window-start through window-end, and for the entire grace period. If not specified, the retention
period would be set as the window length (from window-start through window-end) plus the grace period.

@param retention the retention time
@return itself
@throws IllegalArgumentException if retention is negative or can't be represented as {@code long milliseconds}
streams/src/main/java/org/apache/kafka/streams/kstream/Materialized.java