fix(yuanbao): evict stale entries from _member_cache on TTL expiry

_build_msg_body_with_mentions() checks the TTL of each _member_cache
entry and returns an empty member list when the entry is stale, but
never removes the entry from the dict.  Over time every group_code the
bot has ever queried accumulates a permanent entry, retaining the full
member list (potentially thousands of records per group) until
disconnect().

Fix: delete the stale entry at the point it is detected as expired.
The next call to get_group_member_list_raw() for the same group will
repopulate the cache with fresh data as before.

Symmetric with the existing TTL pattern in MessageDeduplicator, which
evicts on access.
This commit is contained in:
EloquentBrush
2026-05-10 22:46:43 +03:00
committed by kshitij
parent b6511212cf
commit 81c86456af
+5 -1
View File
@@ -4588,7 +4588,11 @@ class MessageSender:
cached = self._adapter._member_cache.get(group_code)
if cached:
ts, member_list = cached
members = member_list if (time.time() - ts < self._adapter.MEMBER_CACHE_TTL_S) else []
if time.time() - ts < self._adapter.MEMBER_CACHE_TTL_S:
members = member_list
else:
del self._adapter._member_cache[group_code]
members = []
else:
members = []
if not members: