Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages should be truncated from cache when Settings::max_messages is lower than current cached messages #2884

Closed
jamesbt365 opened this issue May 30, 2024 · 1 comment

Comments

@jamesbt365
Copy link
Member

I'm not sure if we had this at some point but we certainly don't now, if max messages is reduced at runtime any amount set over the limit is kept.

@ivinjabraham
Copy link
Contributor

ivinjabraham commented Aug 26, 2024

I'll take this up.

I believe that this is the only method to change max_messages at runtime after creation:

    /// Sets the maximum amount of messages per channel to cache.
    ///
    /// By default, no messages will be cached.
    pub fn set_max_messages(&self, max: usize) {
        self.settings.write().max_messages = max;
    }

I'll make it check if the argument max is less than max_messages by reading the settings since checking it after assigning the new value should take more time. And if it is greater, delete the messages from Cache.messages that correspond to the front of Cache.message_queue for each channel's queue. Does that sound good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants