sqlc

package
v1.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 7 Imported by: 283

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is an alias of sqlx.ErrNotFound.
	ErrNotFound = sqlx.ErrNotFound
)

Functions

This section is empty.

Types

type CachedConn

type CachedConn struct {
	// contains filtered or unexported fields
}

A CachedConn is a DB connection with cache capability.

func NewConn

func NewConn(db sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) CachedConn

NewConn returns a CachedConn with a redis cluster cache.

func NewConnWithCache

func NewConnWithCache(db sqlx.SqlConn, c cache.Cache) CachedConn

NewConnWithCache returns a CachedConn with a custom cache.

func NewNodeConn

func NewNodeConn(db sqlx.SqlConn, rds *redis.Redis, opts ...cache.Option) CachedConn

NewNodeConn returns a CachedConn with a redis node cache.

func (CachedConn) DelCache

func (cc CachedConn) DelCache(keys ...string) error

DelCache deletes cache with keys.

func (CachedConn) DelCacheCtx added in v1.3.1

func (cc CachedConn) DelCacheCtx(ctx context.Context, keys ...string) error

DelCacheCtx deletes cache with keys.

func (CachedConn) Exec

func (cc CachedConn) Exec(exec ExecFn, keys ...string) (sql.Result, error)

Exec runs given exec on given keys, and returns execution result.

func (CachedConn) ExecCtx added in v1.3.1

func (cc CachedConn) ExecCtx(ctx context.Context, exec ExecCtxFn, keys ...string) (
	sql.Result, error)

ExecCtx runs given exec on given keys, and returns execution result. If DB operation succeeds, it will delete cache with given keys, if DB operation fails, it will return nil result and non-nil error, if DB operation succeeds but cache deletion fails, it will return result and non-nil error.

func (CachedConn) ExecNoCache

func (cc CachedConn) ExecNoCache(q string, args ...any) (sql.Result, error)

ExecNoCache runs exec with given sql statement, without affecting cache.

func (CachedConn) ExecNoCacheCtx added in v1.3.1

func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, q string, args ...any) (
	sql.Result, error)

ExecNoCacheCtx runs exec with given sql statement, without affecting cache.

func (CachedConn) GetCache

func (cc CachedConn) GetCache(key string, v any) error

GetCache unmarshals cache with given key into v.

func (CachedConn) GetCacheCtx added in v1.3.1

func (cc CachedConn) GetCacheCtx(ctx context.Context, key string, v any) error

GetCacheCtx unmarshals cache with given key into v.

func (CachedConn) QueryRow

func (cc CachedConn) QueryRow(v any, key string, query QueryFn) error

QueryRow unmarshals into v with given key and query func.

func (CachedConn) QueryRowCtx added in v1.3.1

func (cc CachedConn) QueryRowCtx(ctx context.Context, v any, key string, query QueryCtxFn) error

QueryRowCtx unmarshals into v with given key and query func.

func (CachedConn) QueryRowIndex

func (cc CachedConn) QueryRowIndex(v any, key string, keyer func(primary any) string,
	indexQuery IndexQueryFn, primaryQuery PrimaryQueryFn)