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)
| 28 | // Returns: |
| 29 | // - A pointer to a PreparedStmtDB instance, which manages prepared statements using the provided connection pool and configuration. |
| 30 | func 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 |
| 39 | func (db *PreparedStmtDB) GetDBConn() (*sql.DB, error) { |