Source File
unlimited_cache.go
Belonging Package
github.com/jackc/pgx/v5/internal/stmtcache
package stmtcacheimport ()// UnlimitedCache implements Cache with no capacity limit.type UnlimitedCache struct {m map[string]*pgconn.StatementDescriptioninvalidStmts []*pgconn.StatementDescription}// NewUnlimitedCache creates a new UnlimitedCache.func () *UnlimitedCache {return &UnlimitedCache{m: make(map[string]*pgconn.StatementDescription),}}// Get returns the statement description for sql. Returns nil if not found.func ( *UnlimitedCache) ( string) *pgconn.StatementDescription {return .m[]}// Put stores sd in the cache. Put panics if sd.SQL is "". Put does nothing if sd.SQL already exists in the cache.func ( *UnlimitedCache) ( *pgconn.StatementDescription) {if .SQL == "" {panic("cannot store statement description with empty SQL")}if , := .m[.SQL]; {return}.m[.SQL] =}// Invalidate invalidates statement description identified by sql. Does nothing if not found.func ( *UnlimitedCache) ( string) {if , := .m[]; {delete(.m, ).invalidStmts = append(.invalidStmts, )}}// InvalidateAll invalidates all statement descriptions.func ( *UnlimitedCache) () {for , := range .m {.invalidStmts = append(.invalidStmts, )}.m = make(map[string]*pgconn.StatementDescription)}func ( *UnlimitedCache) () []*pgconn.StatementDescription {:= .invalidStmts.invalidStmts = nilreturn}// Len returns the number of cached prepared statement descriptions.func ( *UnlimitedCache) () int {return len(.m)}// Cap returns the maximum number of cached prepared statement descriptions.func ( *UnlimitedCache) () int {return math.MaxInt}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |