MessageLimitConfig

data class MessageLimitConfig(val channelMessageLimits: Set<ChannelMessageLimit> = setOf())

Configuration for message limits in channels.

This configuration allows you to control memory usage by limiting the number of messages kept in the in-memory state for different channel types. When a channel exceeds its configured message limit (plus a 30-message buffer to avoid frequent trimming), the SDK automatically removes the oldest messages from memory while keeping the most recent ones.

Message trimming behavior:

  • Only applies when not loading older messages (to avoid interfering with pagination)

  • Sorts messages by creation time and keeps the most recent ones

  • Sets endOfOlderMessages to false when trimming occurs (indicating more messages exist)

  • Messages are only removed from in-memory state, not from the local database

Use cases:

  • Limit memory usage in channels with extensive message history

  • Optimize performance in resource-constrained environments

  • Configure different limits for different channel types (e.g., smaller limits for group channels, larger for DMs)

Example configuration:

StatePluginConfig(
messageLimitConfig = MessageLimitConfig(
channelMessageLimits = setOf(
ChannelMessageLimit(channelType = "messaging", baseLimit = 1000),
ChannelMessageLimit(channelType = "livestream", baseLimit = 500)
)
)
)

Parameters

channelMessageLimits

A set of ChannelMessageLimit defining the maximum number of messages to keep in memory for different channel types. By default, this is an empty set, meaning no limits are applied and all messages are kept in memory. Each channel type can have its own limit configured independently.

Constructors

Link copied to clipboard
constructor(channelMessageLimits: Set<ChannelMessageLimit> = setOf())

Properties