mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +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();
|
User user = this.plugin.getStorage().loadUser(u, username).join();
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new NullPointerException("User is 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.
|
// Setup defaults for the user
|
||||||
if (save) {
|
boolean save = false;
|
||||||
this.plugin.getStorage().saveUser(user).join();
|
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;
|
final long time = System.currentTimeMillis() - startTime;
|
||||||
if (time >= 1000) {
|
if (time >= 1000) {
|
||||||
this.plugin.getLogger().warn("Processing login for " + username + " took " + time + "ms.");
|
this.plugin.getLogger().warn("Processing login for " + username + " took " + time + "ms.");
|
||||||
|
@ -80,6 +80,11 @@ public class AbstractStorage implements Storage {
|
|||||||
return this.dao;
|
return this.dao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiStorage getApiDelegate() {
|
||||||
|
return this.apiDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
private <T> CompletableFuture<T> makeFuture(Callable<T> supplier) {
|
private <T> CompletableFuture<T> makeFuture(Callable<T> supplier) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
@ -102,11 +107,6 @@ public class AbstractStorage implements Storage {
|
|||||||
}, this.dao.getPlugin().getBootstrap().getScheduler().async());
|
}, this.dao.getPlugin().getBootstrap().getScheduler().async());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApiStorage getApiDelegate() {
|
|
||||||
return this.apiDelegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface ThrowingRunnable {
|
private interface ThrowingRunnable {
|
||||||
void run() throws Exception;
|
void run() throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw reportException(uuid.toString(), e);
|
throw reportException(uuid.toString(), e);
|
||||||
} finally {
|
} finally {
|
||||||
|
user.invalidateCachedData();
|
||||||
user.getIoLock().unlock();
|
user.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
@ -258,6 +259,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw reportException(name, e);
|
throw reportException(name, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
group.invalidateCachedData();
|
||||||
group.getIoLock().unlock();
|
group.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
@ -290,6 +292,7 @@ public abstract class AbstractConfigurateDao extends AbstractDao {
|
|||||||
throw reportException(name, e);
|
throw reportException(name, e);
|
||||||
} finally {
|
} finally {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
|
group.invalidateCachedData();
|
||||||
group.getIoLock().unlock();
|
group.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +286,7 @@ public class MongoDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
user.invalidateCachedData();
|
||||||
user.getIoLock().unlock();
|
user.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
@ -356,6 +357,7 @@ public class MongoDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
group.invalidateCachedData();
|
||||||
group.getIoLock().unlock();
|
group.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
@ -385,6 +387,7 @@ public class MongoDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
|
group.invalidateCachedData();
|
||||||
group.getIoLock().unlock();
|
group.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,6 +355,7 @@ public class SqlDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
user.invalidateCachedData();
|
||||||
user.getIoLock().unlock();
|
user.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
@ -596,6 +597,7 @@ public class SqlDao extends AbstractDao {
|
|||||||
group.clearNodes();
|
group.clearNodes();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
group.invalidateCachedData();
|
||||||
group.getIoLock().unlock();
|
group.getIoLock().unlock();
|
||||||
}
|
}
|
||||||
return Optional.of(group);
|
return Optional.of(group);
|
||||||
|
Loading…
Reference in New Issue
Block a user