feat: 更新SQLite连接配置,启用共享缓存和WAL模式,设置忙等待和内存映射参数
This commit is contained in:
@@ -38,12 +38,12 @@ func loadDialect() map[string]dialectInfo {
|
|||||||
switch item["type"] {
|
switch item["type"] {
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
pragmas := []string{
|
pragmas := []string{
|
||||||
"cache=shared", // Enable shared cache
|
"cache=shared", // Enable shared cache
|
||||||
"_pragma=journal_mode(WAL)", // Enable WAL mode
|
"_pragma=journal_mode(WAL)", // Enable WAL mode
|
||||||
"_pragma=busy_timeout(5000)", // Set busy timeout 抛出 SQLITE_BUSY 错误 默认0立即,设置等待 5 秒(5000 毫秒)
|
"_pragma=busy_timeout(5000)", // Set busy timeout 抛出 SQLITE_BUSY 错误 默认0立即,设置等待 5 秒(5000 毫秒)
|
||||||
"_pragma=synchronous(NORMAL)", // Set synchronous mode
|
"_pragma=synchronous(NORMAL)", // Set synchronous mode
|
||||||
"_pragma=wal_autocheckpoint=5000", // Set WAL auto-checkpoint threshold 设置较大的自动检查点阈值
|
"_pragma=wal_autocheckpoint(5000)", // Set WAL auto-checkpoint threshold 设置较大的自动检查点阈值
|
||||||
"_pragma=mmap_size(67108864)", // Set mmap size 内存映射 I/O 最大字节数为 64MB
|
"_pragma=mmap_size(67108864)", // Set mmap size 内存映射 I/O 最大字节数为 64MB
|
||||||
}
|
}
|
||||||
dsn := fmt.Sprintf("%s?%s", item["database"], strings.Join(pragmas, "&"))
|
dsn := fmt.Sprintf("%s?%s", item["database"], strings.Join(pragmas, "&"))
|
||||||
dialects[key] = dialectInfo{
|
dialects[key] = dialectInfo{
|
||||||
|
|||||||
Reference in New Issue
Block a user