Fix bad caching logic resulting in super high CPU usage
This commit is contained in:
@@ -32,7 +32,6 @@ import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.SimpleConfigurationNode;
|
||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
|
||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||
@@ -67,22 +66,11 @@ public class SpongeConfigAdapter extends AbstractConfigurationAdapter implements
|
||||
}
|
||||
|
||||
private ConfigurationNode resolvePath(String path) {
|
||||
Iterable<String> paths = Splitter.on('.').split(path);
|
||||
ConfigurationNode node = this.root;
|
||||
|
||||
if (node == null) {
|
||||
if (this.root == null) {
|
||||
throw new RuntimeException("Config is not loaded.");
|
||||
}
|
||||
|
||||
for (String s : paths) {
|
||||
node = node.getNode(s);
|
||||
|
||||
if (node == null) {
|
||||
return SimpleConfigurationNode.root();
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
return this.root.getNode(Splitter.on('.').splitToList(path).toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,8 +81,6 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
user.getIoLock().lock();
|
||||
user.getIoLock().unlock();
|
||||
|
||||
// ok, data is here, let's do the pre-calculation stuff.
|
||||
user.preCalculateData();
|
||||
return user.sponge();
|
||||
}
|
||||
|
||||
@@ -94,7 +92,6 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
user.preCalculateData();
|
||||
return user.sponge();
|
||||
});
|
||||
|
||||
|
||||
+4
-22
@@ -448,10 +448,7 @@ public class HolderSubjectData implements LPSubjectData {
|
||||
// handle transient first
|
||||
if (this.type == NodeMapType.TRANSIENT) {
|
||||
// don't bother saving to primary storage. just refresh
|
||||
if (t.getType().isUser()) {
|
||||
User user = ((User) t);
|
||||
return user.reloadCachedData();
|
||||
} else {
|
||||
if (t.getType().isGroup()) {
|
||||
return this.service.getPlugin().getUpdateTaskBuffer().request();
|
||||
}
|
||||
}
|
||||
@@ -459,26 +456,11 @@ public class HolderSubjectData implements LPSubjectData {
|
||||
// handle enduring
|
||||
if (t.getType().isUser()) {
|
||||
User user = ((User) t);
|
||||
CompletableFuture<Void> fut = new CompletableFuture<>();
|
||||
this.service.getPlugin().getStorage().saveUser(user).whenCompleteAsync((v, ex) -> {
|
||||
if (ex != null) {
|
||||
fut.complete(null);
|
||||
}
|
||||
|
||||
user.reloadCachedData().thenAccept(fut::complete);
|
||||
}, this.service.getPlugin().getBootstrap().getScheduler().async());
|
||||
return fut;
|
||||
return this.service.getPlugin().getStorage().saveUser(user);
|
||||
} else {
|
||||
Group group = ((Group) t);
|
||||
CompletableFuture<Void> fut = new CompletableFuture<>();
|
||||
this.service.getPlugin().getStorage().saveGroup(group).whenCompleteAsync((v, ex) -> {
|
||||
if (ex != null) {
|
||||
fut.complete(null);
|
||||
}
|
||||
|
||||
this.service.getPlugin().getUpdateTaskBuffer().request().thenAccept(fut::complete);
|
||||
}, this.service.getPlugin().getBootstrap().getScheduler().async());
|
||||
return fut;
|
||||
return this.service.getPlugin().getStorage().saveGroup(group)
|
||||
.thenCompose(v -> this.service.getPlugin().getUpdateTaskBuffer().request());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class SubjectDataContainer {
|
||||
* @param root the root json object
|
||||
* @return a container representing the json data
|
||||
*/
|
||||
public static SubjectDataContainer derserialize(LPPermissionService service, JsonObject root) {
|
||||
public static SubjectDataContainer deserialize(LPPermissionService service, JsonObject root) {
|
||||
return new SubjectDataContainer(service, root);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ public class SubjectStorage {
|
||||
|
||||
try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
|
||||
JsonObject data = this.gson.fromJson(reader, JsonObject.class);
|
||||
SubjectDataContainer model = SubjectDataContainer.derserialize(this.service, data);
|
||||
SubjectDataContainer model = SubjectDataContainer.deserialize(this.service, data);
|
||||
return new LoadedSubject(subjectName, model);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user