123456789101112131415161718192021222324 |
- package db
- import (
- "sync"
- "github.com/jmoiron/sqlx"
- )
- // *sqlx.NamedStmt pool
- var namedStmtPool = sync.Pool{
- New: func() any {
- return &sqlx.NamedStmt{}
- },
- }
- // NewNamedStmt alloc *sqlx.NamedStmt from pool
- func NewNamedStmt() *sqlx.NamedStmt {
- return namedStmtPool.Get().(*sqlx.NamedStmt)
- }
- // PutNamedStmt release *sqlx.NamedStmt to pool
- func PutNamedStmt(stmt *sqlx.NamedStmt) {
- namedStmtPool.Put(stmt)
- }
|