mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Maybe fix caching issues - closes #99
This commit is contained in:
parent
8795383e7c
commit
35f4aea69f
@ -51,6 +51,7 @@ import me.lucko.luckperms.sponge.managers.SpongeUserManager;
|
||||
import me.lucko.luckperms.sponge.service.base.LPSubject;
|
||||
import me.lucko.luckperms.sponge.service.base.LPSubjectCollection;
|
||||
import me.lucko.luckperms.sponge.service.base.LPSubjectData;
|
||||
import me.lucko.luckperms.sponge.service.calculated.CalculatedSubjectData;
|
||||
import me.lucko.luckperms.sponge.service.calculated.OptionLookup;
|
||||
import me.lucko.luckperms.sponge.service.calculated.PermissionLookup;
|
||||
import me.lucko.luckperms.sponge.service.persisted.PersistedCollection;
|
||||
@ -96,6 +97,7 @@ public class LuckPermsService implements PermissionService {
|
||||
private final Set<LoadingCache<PermissionLookup, Tristate>> localPermissionCaches;
|
||||
private final Set<LoadingCache<ImmutableContextSet, Set<SubjectReference>>> localParentCaches;
|
||||
private final Set<LoadingCache<OptionLookup, Optional<String>>> localOptionCaches;
|
||||
private final Set<CalculatedSubjectData> localDataCaches;
|
||||
|
||||
@Getter(value = AccessLevel.NONE)
|
||||
private final LoadingCache<String, LPSubjectCollection> collections = CacheBuilder.newBuilder()
|
||||
@ -117,6 +119,7 @@ public class LuckPermsService implements PermissionService {
|
||||
localPermissionCaches = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
localParentCaches = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
localOptionCaches = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
localDataCaches = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
|
||||
storage = new SubjectStorage(new File(plugin.getDataFolder(), "local"));
|
||||
|
||||
@ -219,6 +222,9 @@ public class LuckPermsService implements PermissionService {
|
||||
for (LoadingCache<PermissionLookup, Tristate> c : localPermissionCaches) {
|
||||
c.invalidateAll();
|
||||
}
|
||||
for (CalculatedSubjectData subjectData : localDataCaches) {
|
||||
subjectData.invalidateLookupCache();
|
||||
}
|
||||
}
|
||||
|
||||
public void invalidateParentCaches() {
|
||||
|
@ -125,6 +125,10 @@ public class CalculatedSubjectData implements LPSubjectData {
|
||||
permissionCache.cleanUp();
|
||||
}
|
||||
|
||||
public void invalidateLookupCache() {
|
||||
permissionCache.invalidateAll();
|
||||
}
|
||||
|
||||
public Tristate getPermissionValue(ContextSet contexts, String permission) {
|
||||
return permissionCache.getUnchecked(contexts).getCalculator().getPermissionValue(permission);
|
||||
}
|
||||
|
@ -114,6 +114,8 @@ public class PersistedSubject implements LPSubject {
|
||||
this.subjectData = new PersistedSubjectData(service, "local:" + containingCollection.getIdentifier() + "/" + identifier + "(p)", this);
|
||||
this.transientSubjectData = new CalculatedSubjectData(this, service, "local:" + containingCollection.getIdentifier() + "/" + identifier + "(t)");
|
||||
|
||||
service.getLocalDataCaches().add(subjectData);
|
||||
service.getLocalDataCaches().add(transientSubjectData);
|
||||
service.getLocalPermissionCaches().add(permissionLookupCache);
|
||||
service.getLocalParentCaches().add(parentLookupCache);
|
||||
service.getLocalOptionCaches().add(optionLookupCache);
|
||||
|
Loading…
Reference in New Issue
Block a user