Remove LP user cache to fix rollback issues.

This commit is contained in:
bloodshot 2020-02-25 18:36:12 -05:00
parent c4543827eb
commit c1acd88667
2 changed files with 4 additions and 90 deletions

View File

@ -25,17 +25,14 @@
package com.griefdefender.provider;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.collect.ImmutableSet;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.PermissionResult;
import com.griefdefender.api.permission.ResultTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.option.Option;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.ClaimContextCalculator;
@ -80,7 +77,6 @@
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FilenameUtils;
import org.bukkit.Bukkit;
@ -88,11 +84,6 @@
public class LuckPermsProvider implements PermissionProvider {
private final Cache<String, Group> groupCache = Caffeine.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES)
.build();
private final Cache<String, User> userCache = Caffeine.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES)
.build();
public static Comparator<Set<Context>> CONTEXT_COMPARATOR = new Comparator<Set<Context>>() {
@Override
public int compare(Set<Context> s1, Set<Context> s2) {
@ -140,11 +131,7 @@ public PermissionHolder getLuckPermsHolder(GDPermissionHolder holder) {
}
public User getLuckPermsUser(String identifier) {
User user = this.userCache.getIfPresent(identifier);
if (user != null) {
return user;
}
User user = null;
UUID uuid = null;
if (identifier.length() == 36) {
try {
@ -160,9 +147,6 @@ public User getLuckPermsUser(String identifier) {
if (user == null) {
user = this.luckPermsApi.getUserManager().getUser(identifier);
}
if (user != null) {
this.userCache.put(identifier, user);
}
return user;
}
@ -171,16 +155,8 @@ public Group getLuckPermsGroup(String identifier) {
if (identifier.equalsIgnoreCase("default")) {
return this.luckPermsApi.getGroupManager().getGroup("default");
}
Group group = this.groupCache.getIfPresent(identifier);
if (group != null) {
return group;
}
group = this.luckPermsApi.getGroupManager().getGroup(identifier);
if (group != null) {
this.groupCache.put(identifier, group);
}
return group;
return this.luckPermsApi.getGroupManager().getGroup(identifier);
}
public Group getGroupSubject(String identifier) {
@ -198,25 +174,6 @@ public Group getGroupSubject(String identifier) {
}
}
/* public GDPermissionUser getUserSubject(String name) {
final User user = this.luckPermsApi.getUserManager().getUser(name);
if (user != null) {
return new GDPermissionUser(user);
}
try {
final UUID uuid = this.luckPermsApi.getUserManager().lookupUuid(name).get();
if (uuid != null) {
return this.luckPermsApi.getUserManager().loadUser(uuid).get();
}
return null;
} catch (InterruptedException e) {
return null;
} catch (ExecutionException e) {
return null;
}
}*/
public UUID lookupUserUniqueId(String name) {
final User user = this.getLuckPermsUser(name);
if (user != null) {

View File

@ -25,17 +25,14 @@
package com.griefdefender.provider;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.collect.ImmutableSet;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.PermissionResult;
import com.griefdefender.api.permission.ResultTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.option.Option;
import com.griefdefender.cache.PermissionHolderCache;
import com.griefdefender.claim.GDClaim;
@ -79,7 +76,6 @@
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FilenameUtils;
import org.spongepowered.api.Sponge;
@ -87,11 +83,6 @@
public class LuckPermsProvider implements PermissionProvider {
private final Cache<String, Group> groupCache = Caffeine.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES)
.build();
private final Cache<String, User> userCache = Caffeine.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES)
.build();
public static Comparator<Set<Context>> CONTEXT_COMPARATOR = new Comparator<Set<Context>>() {
@Override
public int compare(Set<Context> s1, Set<Context> s2) {
@ -139,11 +130,7 @@ public PermissionHolder getLuckPermsHolder(GDPermissionHolder holder) {
}
public User getLuckPermsUser(String identifier) {
User user = this.userCache.getIfPresent(identifier);
if (user != null) {
return user;
}
User user = null;
UUID uuid = null;
if (identifier.length() == 36) {
try {
@ -159,9 +146,6 @@ public User getLuckPermsUser(String identifier) {
if (user == null) {
user = this.luckPermsApi.getUserManager().getUser(identifier);
}
if (user != null) {
this.userCache.put(identifier, user);
}
return user;
}
@ -170,16 +154,8 @@ public Group getLuckPermsGroup(String identifier) {
if (identifier.equalsIgnoreCase("default")) {
return this.luckPermsApi.getGroupManager().getGroup("default");
}
Group group = this.groupCache.getIfPresent(identifier);
if (group != null) {
return group;
}
group = this.luckPermsApi.getGroupManager().getGroup(identifier);
if (group != null) {
this.groupCache.put(identifier, group);
}
return group;
return this.luckPermsApi.getGroupManager().getGroup(identifier);
}
public Group getGroupSubject(String identifier) {
@ -197,25 +173,6 @@ public Group getGroupSubject(String identifier) {
}
}
/* public GDPermissionUser getUserSubject(String name) {
final User user = this.luckPermsApi.getUserManager().getUser(name);
if (user != null) {
return new GDPermissionUser(user);
}
try {
final UUID uuid = this.luckPermsApi.getUserManager().lookupUuid(name).get();
if (uuid != null) {
return this.luckPermsApi.getUserManager().loadUser(uuid).get();
}
return null;
} catch (InterruptedException e) {
return null;
} catch (ExecutionException e) {
return null;
}
}*/
public UUID lookupUserUniqueId(String name) {
final User user = this.getLuckPermsUser(name);
if (user != null) {