Add Database.MySQL.Max_Lifetime settings

This commit is contained in:
Aurora Lahtela 2023-04-16 15:53:51 +03:00
parent 08e13cfddb
commit 10383da94a
4 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,7 @@ package com.djrapitops.plan.settings.config.paths;
import com.djrapitops.plan.settings.config.paths.key.IntegerSetting;
import com.djrapitops.plan.settings.config.paths.key.Setting;
import com.djrapitops.plan.settings.config.paths.key.StringSetting;
import com.djrapitops.plan.settings.config.paths.key.TimeSetting;
import com.djrapitops.plan.storage.database.DBType;
import org.apache.commons.lang3.math.NumberUtils;
@ -37,6 +38,7 @@ public class DatabaseSettings {
public static final Setting<String> MYSQL_DATABASE = new StringSetting("Database.MySQL.Database");
public static final Setting<String> MYSQL_LAUNCH_OPTIONS = new StringSetting("Database.MySQL.Launch_options");
public static final Setting<Integer> MAX_CONNECTIONS = new IntegerSetting("Database.MySQL.Max_connections", value -> value > 0);
public static final Setting<Long> MAX_LIFETIME = new TimeSetting("Database.MySQL.Max_Lifetime");
private DatabaseSettings() {
/* static variable class */

View File

@ -126,7 +126,7 @@ public class MySQLDB extends SQLDB {
hikariConfig.setAutoCommit(false);
setMaxConnections(hikariConfig);
hikariConfig.setMaxLifetime(TimeUnit.MINUTES.toMillis(25L));
hikariConfig.setMaxLifetime(config.get(DatabaseSettings.MAX_LIFETIME));
hikariConfig.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(29L));
this.dataSource = new HikariDataSource(hikariConfig);

View File

@ -35,6 +35,9 @@ Database:
# Launch options to append after mysql driver address
Launch_options: "?rewriteBatchedStatements=true&useSSL=false&serverTimezone=UTC"
Max_connections: 8
Max_Lifetime:
Time: 25
Unit: MINUTES
# -----------------------------------------------------
# More information about SSL Certificate Settings:
# https://github.com/plan-player-analytics/Plan/wiki/SSL-Certificate-%28HTTPS%29-Set-Up

View File

@ -36,6 +36,9 @@ Database:
# Launch options to append after mysql driver address
Launch_options: "?rewriteBatchedStatements=true&useSSL=false&serverTimezone=UTC"
Max_connections: 8
Max_Lifetime:
Time: 25
Unit: MINUTES
# -----------------------------------------------------
# More information about SSL Certificate Settings:
# https://github.com/plan-player-analytics/Plan/wiki/SSL-Certificate-%28HTTPS%29-Set-Up