Avoid running full "update tasks" unless they're absolutely needed. Process Vault API "set" requests immediately instead of in the background
This commit is contained in:
@@ -130,7 +130,8 @@ public final class StorageAssistant {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
plugin.getGroupManager().invalidateAllGroupCaches();
|
||||
plugin.getUserManager().invalidateAllUserCaches();
|
||||
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
@@ -154,7 +155,8 @@ public final class StorageAssistant {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
plugin.getGroupManager().invalidateAllGroupCaches();
|
||||
plugin.getUserManager().invalidateAllUserCaches();
|
||||
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) {
|
||||
|
||||
+6
@@ -27,6 +27,7 @@ package me.lucko.luckperms.common.managers.group;
|
||||
|
||||
import me.lucko.luckperms.common.managers.AbstractManager;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -63,4 +64,9 @@ public abstract class AbstractGroupManager<T extends Group> extends AbstractMana
|
||||
protected String sanitizeIdentifier(String s) {
|
||||
return s.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateAllGroupCaches() {
|
||||
getAll().values().forEach(PermissionHolder::invalidateCachedData);
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,9 @@ public interface GroupManager<T extends Group> extends Manager<String, Group, T>
|
||||
*/
|
||||
T getByDisplayName(String name);
|
||||
|
||||
/**
|
||||
* Invalidates the cached data for *loaded* groups.
|
||||
*/
|
||||
void invalidateAllGroupCaches();
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.managers.AbstractManager;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
@@ -153,6 +154,11 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateAllUserCaches() {
|
||||
getAll().values().forEach(PermissionHolder::invalidateCachedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the user's state indicates that they should be persisted to storage.
|
||||
*
|
||||
|
||||
@@ -80,8 +80,13 @@ public interface UserManager<T extends User> extends Manager<UserIdentifier, Use
|
||||
void cleanup(User user);
|
||||
|
||||
/**
|
||||
* Reloads the data of all online users
|
||||
* Reloads the data of all *online* users
|
||||
*/
|
||||
CompletableFuture<Void> updateAllUsers();
|
||||
|
||||
/**
|
||||
* Invalidates the cached data for *loaded* users.
|
||||
*/
|
||||
void invalidateAllUserCaches();
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ public class ExpireTemporaryTask implements Runnable {
|
||||
}
|
||||
|
||||
if (groupChanges) {
|
||||
this.plugin.getUpdateTaskBuffer().request();
|
||||
this.plugin.getGroupManager().invalidateAllGroupCaches();
|
||||
this.plugin.getUserManager().invalidateAllUserCaches();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ public class UpdateTask implements Runnable {
|
||||
this.plugin.getStorage().loadAllTracks().join();
|
||||
|
||||
// Refresh all online users.
|
||||
this.plugin.getUserManager().invalidateAllUserCaches();
|
||||
CompletableFuture<Void> userUpdateFut = this.plugin.getUserManager().updateAllUsers();
|
||||
if (!this.initialUpdate) {
|
||||
userUpdateFut.join();
|
||||
|
||||
Reference in New Issue
Block a user