Documentation
¶
Index ¶
- Variables
- func QueryCacheKey(statement string, args ...any) string
- type CachedDB
- func (db *CachedDB) BatchInsert(ctx context.Context, batch capsql.BatchInsert) (capsql.Result, error)
- func (db *CachedDB) Begin(ctx context.Context) (capsql.Tx, error)
- func (db *CachedDB) CachedQuery(ctx context.Context, key string, ttl time.Duration, load CachedLoader) ([]byte, error)
- func (db *CachedDB) CachedQueryRow(ctx context.Context, key string, ttl time.Duration, load CachedLoader) ([]byte, error)
- func (db *CachedDB) Delete(ctx context.Context, key string) error
- func (db *CachedDB) Exec(ctx context.Context, query string, args ...any) (capsql.Result, error)
- func (db *CachedDB) Invalidate(ctx context.Context, key string) error
- func (db *CachedDB) Prepare(ctx context.Context, query string) (capsql.Stmt, error)
- func (db *CachedDB) Query(ctx context.Context, query string, args ...any) (capsql.Rows, error)
- func (db *CachedDB) QueryRow(ctx context.Context, query string, args ...any) capsql.Row
- func (db *CachedDB) WithTransaction(ctx context.Context, fn func(context.Context, capsql.Tx) error) error
- type CachedDBConfig
- type CachedLoader
- type Config
- type DB
- func (db *DB) BatchInsert(ctx context.Context, batch capsql.BatchInsert) (capsql.Result, error)
- func (db *DB) Begin(ctx context.Context) (capsql.Tx, error)
- func (db *DB) Close() error
- func (db *DB) Exec(ctx context.Context, statement string, args ...any) (capsql.Result, error)
- func (db *DB) Prepare(ctx context.Context, statement string) (capsql.Stmt, error)
- func (db *DB) Query(ctx context.Context, statement string, args ...any) (capsql.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, statement string, args ...any) capsql.Row
- func (db *DB) ReportHealth(ctx context.Context) (caphealth.Report, error)
- func (db *DB) Stats() stdsql.DBStats
- func (db *DB) WithTransaction(ctx context.Context, fn func(context.Context, capsql.Tx) error) error
- type Factory
- func (f *Factory) BatchInsert(ctx context.Context, batch capsql.BatchInsert) (capsql.Result, error)
- func (f *Factory) Begin(ctx context.Context) (capsql.Tx, error)
- func (f *Factory) DB(name string) (capsql.DB, bool)
- func (f *Factory) Default() capsql.DB
- func (f *Factory) Exec(ctx context.Context, query string, args ...any) (capsql.Result, error)
- func (f *Factory) MustDB(name string) capsql.DB
- func (f *Factory) Prepare(ctx context.Context, query string) (capsql.Stmt, error)
- func (f *Factory) Query(ctx context.Context, query string, args ...any) (capsql.Rows, error)
- func (f *Factory) QueryRow(ctx context.Context, query string, args ...any) capsql.Row
- func (f *Factory) WithTransaction(ctx context.Context, fn func(context.Context, capsql.Tx) error) error
- type FactoryConfig
- type Router
- func (r *Router) BatchInsert(ctx context.Context, batch capsql.BatchInsert) (capsql.Result, error)
- func (r *Router) Begin(ctx context.Context) (capsql.Tx, error)
- func (r *Router) Exec(ctx context.Context, query string, args ...any) (capsql.Result, error)
- func (r *Router) Prepare(ctx context.Context, query string) (capsql.Stmt, error)
- func (r *Router) Query(ctx context.Context, query string, args ...any) (capsql.Rows, error)
- func (r *Router) QueryRow(ctx context.Context, query string, args ...any) capsql.Row
- func (r *Router) WithTransaction(ctx context.Context, fn func(context.Context, capsql.Tx) error) error
- type RouterConfig
- type SlowQueryEvent
- type SlowQueryHook
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheInvalidationUnsupported = errors.New("sql cache invalidation unsupported")
Functions ¶
func QueryCacheKey ¶
Types ¶
type CachedDB ¶
type CachedDB struct {
// contains filtered or unexported fields
}
func NewCachedDB ¶
func NewCachedDB(cfg CachedDBConfig) (*CachedDB, error)
func (*CachedDB) BatchInsert ¶
func (*CachedDB) CachedQuery ¶
func (*CachedDB) CachedQueryRow ¶
type CachedDBConfig ¶
type Config ¶
type Config struct {
Name string
DSN string
Driver string
Dialect capsql.Dialect
DB *stdsql.DB
Hooks []capsql.QueryHook
SlowQueryThreshold time.Duration
SlowQueryHook SlowQueryHook
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
PingTimeout time.Duration
HealthQuery string
}
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) BatchInsert ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
func NewFactory(cfg FactoryConfig) (*Factory, error)
func (*Factory) BatchInsert ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(cfg RouterConfig) (*Router, error)
func (*Router) BatchInsert ¶
type SlowQueryEvent ¶
type SlowQueryEvent struct {
Metadata capsql.QueryMetadata
Threshold time.Duration
}
type SlowQueryHook ¶
type SlowQueryHook func(ctx context.Context, event SlowQueryEvent)
Click to show internal directories.
Click to hide internal directories.