Skip to content

Commit 64cfb10

Browse files
NeglectDreamJRoy
andauthored
Optimize cached online user lookups (#6595)
Co-authored-by: JRoy <10731363+JRoy@users.noreply.github.com>
1 parent ee9f6f9 commit 64cfb10

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ public User getUser(final UUID uuid) {
102102

103103
@Override
104104
public User getUser(final Player base) {
105+
final UUID uuid = base.getUniqueId();
106+
final User cachedUser = userCache.getIfPresent(uuid);
107+
if (cachedUser != null && cachedUser.getBase() == base) {
108+
uuidCache.updateCache(uuid, base.getName());
109+
return cachedUser;
110+
}
111+
105112
final User user = loadUncachedUser(base);
106113
userCache.put(user.getUUID(), user);
107114
debugLogCache(user);

0 commit comments

Comments
 (0)