From ecf239d2a2e6ee8e027ca5fef9acf4564a9f3a09 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 29 Jul 2021 01:43:23 -0400 Subject: Fix user cache acting incorrectly with evictions The first issue involved copied users which would lead to user updates causing faster evictions of the cache than was expected. The second issue involved users that weren't bound to an internal lifetime eviction policy. These users would not get evicted. For example, a user without mutual guilds or being part of the internal cache in general (messages, DMs) would never end up being evicted for some strange reason. To handle this case, store_user would get a counterpart named create_user which would create a user without potentially storing them in the cache. That way only users with a bound lifetime within the library would be stored. --- discord/webhook/async_.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'discord/webhook') diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index c5e93408..58bbbd21 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -597,6 +597,9 @@ class _WebhookState: return self._parent.store_user(data) return BaseUser(state=self, data=data) + def create_user(self, data): + return BaseUser(state=self, data=data) + @property def http(self): if self._parent is not None: -- cgit v1.2.3