File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/main/java/com/btk5h/skriptdb/skript Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import org .bukkit .event .Event ;
6
6
7
+ import java .util .HashMap ;
8
+ import java .util .Map ;
9
+
7
10
import ch .njol .skript .Skript ;
8
11
import ch .njol .skript .lang .Expression ;
9
12
import ch .njol .skript .lang .ExpressionType ;
@@ -30,6 +33,8 @@ public class ExprDataSource extends SimpleExpression<HikariDataSource> {
30
33
ExpressionType .COMBINED , "[the] data(base|[ ]source) [(of|at)] %string%" );
31
34
}
32
35
36
+ private static Map <String , HikariDataSource > connectionCache = new HashMap <>();
37
+
33
38
private Expression <String > url ;
34
39
35
40
@ Override
@@ -43,9 +48,15 @@ protected HikariDataSource[] get(Event e) {
43
48
jdbcUrl = "jdbc:" + jdbcUrl ;
44
49
}
45
50
51
+ if (connectionCache .containsKey (jdbcUrl )) {
52
+ return new HikariDataSource []{connectionCache .get (jdbcUrl )};
53
+ }
54
+
46
55
HikariDataSource ds = new HikariDataSource ();
47
56
ds .setJdbcUrl (jdbcUrl );
48
57
58
+ connectionCache .put (jdbcUrl , ds );
59
+
49
60
return new HikariDataSource []{ds };
50
61
}
51
62
You can’t perform that action at this time.
0 commit comments