func (c *LRU) Get(ctx context.Context, sql string) (*pgconn.StatementDescription, error) {
	txStatus := c.conn.TxStatus()
	if (txStatus == 'I' || txStatus == 'T') && len(c.stmtsToClear) > 0 {
		for _, stmt := range c.stmtsToClear {
			err := c.clearStmt(ctx, stmt)
			if err != nil {
				return nil, err
			}
		}
	}
	if el, ok := c.m[sql]; ok {
		c.l.MoveToFront(el)
		return el.Value.(*pgconn.StatementDescription), nil
	}
	if c.l.Len() == c.cap {
		err := c.removeOldest(ctx)
		if err != nil {
			return nil, err
		}
	}
	psd, err := c.prepare(ctx, sql)
	if err != nil {
		return nil, err
	}
	el := c.l.PushFront(psd)
	c.m[sql] = el
	return psd, nil
}
Get returns the prepared statement description for sql preparing or describing the sql on the server as needed.
package stmtcache
import (
	"container/list"
	"context"
	"fmt"
	"sync/atomic"
	"github.com/jackc/pgconn"
)
var lruCount uint64
type LRU struct {
	conn         *pgconn.PgConn
	mode         int
	cap          int
	prepareCount int
	m            map[string]*list.Element
	l            *list.List
	psNamePrefix string
	stmtsToClear []string
}
func NewLRU(conn *pgconn.PgConn, mode int, cap int) *LRU {
	mustBeValidMode(mode)
	mustBeValidCap(cap)
	n := atomic.AddUint64(&lruCount, 1)
	return &LRU{
		conn:         conn,
		mode:         mode,
		cap:          cap,
		m:            make(map[string]*list.Element),
		l:            list.New(),
		psNamePrefix: fmt.Sprintf("lrupsc_%d", n),
	}
}