MCPcopy
hub / github.com/go-gorm/gorm / NewPreparedStmtDB

Function NewPreparedStmtDB

prepare_stmt.go:30–36  ·  view source on GitHub ↗

NewPreparedStmtDB creates and initializes a new instance of PreparedStmtDB. Parameters: - connPool: A connection pool that implements the ConnPool interface, used for managing database connections. - maxSize: The maximum number of prepared statements that can be stored in the statement store. - ttl

(connPool ConnPool, maxSize int, ttl time.Duration)

Source from the content-addressed store, hash-verified

28// Returns:
29// - A pointer to a PreparedStmtDB instance, which manages prepared statements using the provided connection pool and configuration.
30func NewPreparedStmtDB(connPool ConnPool, maxSize int, ttl time.Duration) *PreparedStmtDB {
31 return &PreparedStmtDB{
32 ConnPool: connPool, // Assigns the provided connection pool to manage database connections.
33 Stmts: stmt_store.New(maxSize, ttl), // Initializes a new statement store with the specified maximum size and TTL.
34 Mux: &sync.RWMutex{}, // Sets up a read-write mutex for synchronizing access to the statement store.
35 }
36}
37
38// GetDBConn returns the underlying *sql.DB connection
39func (db *PreparedStmtDB) GetDBConn() (*sql.DB, error) {

Callers 2

OpenFunction · 0.85
SessionMethod · 0.85

Calls 1

NewFunction · 0.92

Tested by

no test coverage detected