mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 03:34:42 +02:00
Add UUID caching
This commit is contained in:
@ -37,6 +37,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
@ -121,4 +122,24 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the entire cache at once
|
||||
*
|
||||
* @return All read mappings
|
||||
*/
|
||||
@NotNull public List<UUIDMapping> getAll() {
|
||||
final List<UUIDMapping> mappings = new LinkedList<>();
|
||||
try (final PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM `usercache`")) {
|
||||
try (final ResultSet resultSet = statement.executeQuery()) {
|
||||
while (resultSet.next()) {
|
||||
mappings.add(new UUIDMapping(UUID.fromString(resultSet.getString("uuid")), resultSet.getString("username")));
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user