mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Fix cache invalidation when group data changes (#1010)
This commit is contained in:
parent
f4882c1c14
commit
a90e59ec97
@ -77,21 +77,21 @@ public abstract class AbstractConnectionListener implements ConnectionListener {
|
||||
User user = this.plugin.getStorage().loadUser(u, username).join();
|
||||
if (user == null) {
|
||||
throw new NullPointerException("User is null");
|
||||
} else {
|
||||
// Setup defaults for the user
|
||||
boolean save = false;
|
||||
for (AssignmentRule rule : this.plugin.getConfiguration().get(ConfigKeys.DEFAULT_ASSIGNMENTS)) {
|
||||
if (rule.apply(user)) {
|
||||
save = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If they were given a default, persist the new assignments back to the storage.
|
||||
if (save) {
|
||||
this.plugin.getStorage().saveUser(user).join();
|
||||
// Setup defaults for the user
|
||||
boolean save = false;
|
||||
for (AssignmentRule rule : this.plugin.getConfiguration().get(ConfigKeys.DEFAULT_ASSIGNMENTS)) {
|
||||
if (rule.apply(user)) {
|
||||
save = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If they were given a default, persist the new assignments back to the storage.
|
||||
if (save) {
|
||||
this.plugin.getStorage().saveUser(user).join();
|
||||
}
|
||||
|
||||
final long time = System.currentTimeMillis() - startTime;
|
||||
if (time >= 1000) {
|
||||
this.plugin.getLogger().warn("Processing login for " + username + " took " + time + "ms.");
|
||||
|
@ -80,6 +80,11 @@ public class AbstractStorage implements Storage {
|
||||
return this.dao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiStorage getApiDelegate() {
|
||||
return this.apiDelegate;
|
||||
}
|
||||
|
||||
private <T> CompletableFuture<T> makeFuture(Callable<T> supplier) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
@ -102,11 +107,6 @@ public class AbstractStorage implements Storage {
|
||||
}, this.dao.getPlugin().getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiStorage getApiDelegate() {
|
||||
return this.apiDelegate;
|
||||
}
|
||||
|
||||
private interface ThrowingRunnable {
|
||||
void run() throws Exception;
|
||||
}
|
||||
|
@ -203,6 +203,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
||||
} catch (Exception e) {
|
||||
throw reportException(uuid.toString(), e);
|
||||
} finally {
|
||||
user.invalidateCachedData();
|
||||
user.getIoLock().unlock();
|
||||
}
|
||||
return user;
|
||||
@ -258,6 +259,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
||||
} catch (Exception e) {
|
||||
throw reportException(name, e);
|
||||
} finally {
|
||||
group.invalidateCachedData();
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
return group;
|
||||
@ -290,6 +292,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
||||
throw reportException(name, e);
|
||||
} finally {
|
||||
if (group != null) {
|
||||
group.invalidateCachedData();
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
@ -286,6 +286,7 @@ public class MongoDao extends AbstractDao {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
user.invalidateCachedData();
|
||||
user.getIoLock().unlock();
|
||||
}
|
||||
return user;
|
||||
@ -356,6 +357,7 @@ public class MongoDao extends AbstractDao {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
group.invalidateCachedData();
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
return group;
|
||||
@ -385,6 +387,7 @@ public class MongoDao extends AbstractDao {
|
||||
}
|
||||
} finally {
|
||||
if (group != null) {
|
||||
group.invalidateCachedData();
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
@ -355,6 +355,7 @@ public class SqlDao extends AbstractDao {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
user.invalidateCachedData();
|
||||
user.getIoLock().unlock();
|
||||
}
|
||||
return user;
|
||||
@ -596,6 +597,7 @@ public class SqlDao extends AbstractDao {
|
||||
group.clearNodes();
|
||||
}
|
||||
} finally {
|
||||
group.invalidateCachedData();
|
||||
group.getIoLock().unlock();
|
||||
}
|
||||
return Optional.of(group);
|
||||
|
Loading…
Reference in New Issue
Block a user