format code and add session level prepare stmt config
This commit is contained in:
parent
f4e7282442
commit
29a3f7e7c4
4
gorm.go
4
gorm.go
@ -110,6 +110,8 @@ type DB struct {
|
|||||||
type Session struct {
|
type Session struct {
|
||||||
DryRun bool
|
DryRun bool
|
||||||
PrepareStmt bool
|
PrepareStmt bool
|
||||||
|
PrepareStmtMaxSize int
|
||||||
|
PrepareStmtTTL time.Duration
|
||||||
NewDB bool
|
NewDB bool
|
||||||
Initialized bool
|
Initialized bool
|
||||||
SkipHooks bool
|
SkipHooks bool
|
||||||
@ -273,7 +275,7 @@ func (db *DB) Session(config *Session) *DB {
|
|||||||
if v, ok := db.cacheStore.Load(preparedStmtDBKey); ok {
|
if v, ok := db.cacheStore.Load(preparedStmtDBKey); ok {
|
||||||
preparedStmt = v.(*PreparedStmtDB)
|
preparedStmt = v.(*PreparedStmtDB)
|
||||||
} else {
|
} else {
|
||||||
preparedStmt = NewPreparedStmtDB(db.ConnPool, db.Config.PrepareStmtMaxSize, db.Config.PrepareStmtTTL)
|
preparedStmt = NewPreparedStmtDB(db.ConnPool, config.PrepareStmtMaxSize, config.PrepareStmtTTL)
|
||||||
db.cacheStore.Store(preparedStmtDBKey, preparedStmt)
|
db.cacheStore.Store(preparedStmtDBKey, preparedStmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package lru
|
package lru
|
||||||
|
|
||||||
// golang -lru
|
// golang -lru
|
||||||
//https://github.com/hashicorp/golang-lru
|
// https://github.com/hashicorp/golang-lru
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -226,7 +226,7 @@ func (c *LRU[K, V]) KeyValues() map[K]V {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
maps[ent.Key] = ent.Value
|
maps[ent.Key] = ent.Value
|
||||||
//keys = append(keys, ent.Key)
|
// keys = append(keys, ent.Key)
|
||||||
}
|
}
|
||||||
return maps
|
return maps
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user