支持lru缓存
This commit is contained in:
parent
057f5fdcd6
commit
565375dfb7
@ -24,10 +24,7 @@ type PreparedStmtDB struct {
|
||||
ConnPool
|
||||
}
|
||||
|
||||
func NewPreparedStmtDB(connPool ConnPool, prepareStmtLruConfig *PrepareStmtLruConfig) *PreparedStmtDB {
|
||||
return &PreparedStmtDB{
|
||||
ConnPool: connPool,
|
||||
Stmts: func() StmtStore {
|
||||
func newPrepareStmtCache(prepareStmtLruConfig *PrepareStmtLruConfig) *StmtStore {
|
||||
var stmts StmtStore
|
||||
if prepareStmtLruConfig != nil && prepareStmtLruConfig.Open {
|
||||
if prepareStmtLruConfig.Size <= 0 {
|
||||
@ -40,8 +37,12 @@ func NewPreparedStmtDB(connPool ConnPool, prepareStmtLruConfig *PrepareStmtLruCo
|
||||
defaultStmtStore := &DefaultStmtStore{}
|
||||
stmts = defaultStmtStore.init()
|
||||
}
|
||||
return stmts
|
||||
}(),
|
||||
return &stmts
|
||||
}
|
||||
func NewPreparedStmtDB(connPool ConnPool, prepareStmtLruConfig *PrepareStmtLruConfig) *PreparedStmtDB {
|
||||
return &PreparedStmtDB{
|
||||
ConnPool: connPool,
|
||||
Stmts: *newPrepareStmtCache(prepareStmtLruConfig),
|
||||
Mux: &sync.RWMutex{},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user