Refactor the way holder caches are invalidated in order to improve consistency (#734)
This commit is contained in:
@@ -85,11 +85,6 @@ public class SpongeConfigAdapter extends AbstractConfigurationAdapter implements
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String path) {
|
||||
return !resolvePath(path).isVirtual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path, String def) {
|
||||
return resolvePath(path).getString(def);
|
||||
|
||||
@@ -37,6 +37,13 @@ public class SpongeGroup extends Group implements SpongePermissionHolder {
|
||||
this.spongeData = new GroupSubject(plugin, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateCache() {
|
||||
super.invalidateCache();
|
||||
|
||||
this.spongeData.fireUpdateEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupSubject sponge() {
|
||||
return this.spongeData;
|
||||
|
||||
@@ -48,6 +48,13 @@ public class SpongeUser extends User implements SpongePermissionHolder {
|
||||
this.spongeData = new UserSubject(plugin, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateCache() {
|
||||
super.invalidateCache();
|
||||
|
||||
this.spongeData.fireUpdateEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserSubject sponge() {
|
||||
return this.spongeData;
|
||||
|
||||
@@ -66,12 +66,11 @@ public abstract class HolderSubject<T extends PermissionHolder> implements LPSub
|
||||
this.plugin = plugin;
|
||||
this.subjectData = new HolderSubjectData(plugin.getService(), NodeMapType.ENDURING, parent, this);
|
||||
this.transientSubjectData = new HolderSubjectData(plugin.getService(), NodeMapType.TRANSIENT, parent, this);
|
||||
}
|
||||
|
||||
// fire update event
|
||||
parent.getStateListeners().add(() -> {
|
||||
plugin.getUpdateEventHandler().fireUpdateEvent(this.subjectData);
|
||||
plugin.getUpdateEventHandler().fireUpdateEvent(this.transientSubjectData);
|
||||
});
|
||||
public void fireUpdateEvent() {
|
||||
this.plugin.getUpdateEventHandler().fireUpdateEvent(this.subjectData);
|
||||
this.plugin.getUpdateEventHandler().fireUpdateEvent(this.transientSubjectData);
|
||||
}
|
||||
|
||||
public T getParent() {
|
||||
|
||||
+2
-2
@@ -450,7 +450,7 @@ public class HolderSubjectData implements LPSubjectData {
|
||||
// don't bother saving to primary storage. just refresh
|
||||
if (t.getType().isUser()) {
|
||||
User user = ((User) t);
|
||||
return user.getRefreshBuffer().request();
|
||||
return user.reloadCachedData();
|
||||
} else {
|
||||
return this.service.getPlugin().getUpdateTaskBuffer().request();
|
||||
}
|
||||
@@ -465,7 +465,7 @@ public class HolderSubjectData implements LPSubjectData {
|
||||
fut.complete(null);
|
||||
}
|
||||
|
||||
user.getRefreshBuffer().request().thenAccept(fut::complete);
|
||||
user.reloadCachedData().thenAccept(fut::complete);
|
||||
}, this.service.getPlugin().getBootstrap().getScheduler().async());
|
||||
return fut;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user