serenity-rs / serenity

A Rust library for the Discord API.
https://discord.gg/serenity-rs
ISC License
4.65k stars 571 forks source link

Cache results of methods that request data using `Http` #2869

Open jamesbt365 opened 3 months ago

jamesbt365 commented 3 months ago

A lot of methods that request data do not cache the result, leading to requesting information far more often than is actually needed. We should scrub through and try and cache as much information as possible to prevent the need to request it twice.

This is a problem on both current and next.

For example, Guild and GuildId do not cache the request of the Http request on the member method, this happens all across the library for methods that fetch data.

sarahkittyy commented 2 months ago

+1, I am calling GuildId::member on 15 or so users and the fact that it's not cached is making the command take like 10 seconds. I don't even know how I would manually add it to the cache.