feat: improve user caching#387
Open
Droid00000 wants to merge 1 commit into
Open
Conversation
45dc5aa to
8dd6c87
Compare
89908ab to
19d70f8
Compare
a45f255 to
d29f9d9
Compare
4ed0d2e to
c332542
Compare
06435ce to
f3b1b55
Compare
d9ddcc9 to
6056e0e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Using
Bot#ensure_userhas a small problem. User objects that are cached aren't ever updated sansGUILD_MEMBER_UPDATEandPRESENCE_UPDATEevents. For bots that can't use these events, this isn't good. For example, say someone runs a slash command, changes their nameplate, and then runs the command again. The cache won't be updated the second time the command is run, and we'll have stale data.I think the most non-intrusive way to solve this is to introduce a
force_cacheargument, like we do withBot#ensure_server. This way, we can update the cached object with new data if it already exists. Any other ideas and ways to solve this are welcome, this is just what I managed to come up withAdded
force_cacheparameter toBot#ensure_user