-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDatabaseConfig.java
More file actions
115 lines (98 loc) · 2.95 KB
/
DatabaseConfig.java
File metadata and controls
115 lines (98 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.yirankuma.yrdatabase.api.config;
import lombok.Data;
/**
* Database configuration.
*
* @author YiranKuma
*/
@Data
public class DatabaseConfig {
/**
* Operating mode: standalone or cluster.
*/
private String mode = "standalone";
/**
* Cache layer configuration.
*/
private CacheConfig cache = new CacheConfig();
/**
* Persistence layer configuration.
*/
private PersistConfig persist = new PersistConfig();
/**
* Caching strategy configuration.
*/
private CachingConfig caching = new CachingConfig();
/**
* Session management configuration.
*/
private SessionConfig session = new SessionConfig();
/**
* Advanced options.
*/
private AdvancedConfig advanced = new AdvancedConfig();
@Data
public static class CacheConfig {
private boolean enabled = true;
private String type = "redis";
private String host = "localhost";
private int port = 6379;
private String password = "";
private int database = 0;
private int timeout = 5000;
private PoolConfig pool = new PoolConfig();
@Data
public static class PoolConfig {
private int maxTotal = 20;
private int maxIdle = 10;
private int minIdle = 2;
}
}
@Data
public static class PersistConfig {
private boolean enabled = true;
private String type = "mysql";
private MySQLConfig mysql = new MySQLConfig();
private SQLiteConfig sqlite = new SQLiteConfig();
@Data
public static class MySQLConfig {
private String host = "localhost";
private int port = 3306;
private String database = "yrdatabase";
private String username = "root";
private String password = "";
private String timezone = "Asia/Shanghai";
private PoolConfig pool = new PoolConfig();
@Data
public static class PoolConfig {
private int maxSize = 10;
private int minIdle = 2;
private long connectionTimeout = 30000;
private long idleTimeout = 600000;
private long maxLifetime = 1800000;
}
}
@Data
public static class SQLiteConfig {
private String file = "data/yrdatabase.db";
}
}
@Data
public static class CachingConfig {
private long defaultTTL = 3600;
private boolean autoRefresh = true;
private long refreshThreshold = 300;
}
@Data
public static class SessionConfig {
private long timeout = 300000;
private long heartbeatInterval = 10000;
private long messageExpiry = 30000;
}
@Data
public static class AdvancedConfig {
private int asyncExecutorSize = 4;
private boolean enableMetrics = false;
private boolean debugMode = false;
}
}