-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fix getMemberOrNull and getGuildMembers caching only user data #964
Fix getMemberOrNull and getGuildMembers caching only user data #964
Conversation
You want to store both |
For override suspend fun getMemberOrNull(guildId: Snowflake, userId: Snowflake): Member? {
return storeAndReturn(supplier.getMemberOrNull(guildId, userId)) {
cache.put(it.data)
it.memberData
}
} or without override suspend fun getMemberOrNull(guildId: Snowflake, userId: Snowflake): Member? {
return supplier.getMemberOrNull(guildId, userId)?.also {
cache.put(it.data)
cache.put(it.memberData)
}
} For Should additional utility functions be added for these single uses? Alternative for override fun getGuildMembers(guildId: Snowflake, limit: Int?): Flow<Member> {
return supplier.getGuildMembers(guildId, limit).onEach {
cache.put(it.data)
cache.put(it.memberData)
}
} |
Yes, I'd prefer something like this.
I think we don't need an extra function and make it complicated, keeping it simple with something like your alternative should be fine. Note that in both cases using an expression body function and a named lambda parameter instead of |
Changes applied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
As reported in Discord, these calls are storing the results to the user cache, so subsequent calls would not find them from cache.
When using
cacheWithCachingRestFallback
, this results in REST calls being made every single time to get members, unless they got cached from a gateway event.