sqlc

package
v0.0.0-...-d5d5ef8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 8 Imported by: 0

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

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

DelCacheCtx deletes cache with keys.

func (CachedConn) DelxCache

func (cc CachedConn) DelxCache(key string, fields ...string) error

DelCache deletes cache with keys.

func (CachedConn) DelxCacheCtx

func (cc CachedConn) DelxCacheCtx(ctx context.Context, key string, fields ...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

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.

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

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) Execx

func (cc CachedConn) Execx(exec ExecxFn, key string, fields ...string) (sql.Result, error)

Execx runs given exec on given key and fields, and returns execution result.

func (CachedConn) ExecxCtx

func (cc CachedConn) ExecxCtx(ctx context.Context, exec ExecxCtxFn, key string, fields ...string) (
	sql.Result, error)

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

func (CachedConn) GetCache

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

GetCache unmarshals cache with given key into v.

func (CachedConn) GetCacheCtx

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

GetCacheCtx unmarshals cache with given key into v.

func (CachedConn) GetRedis

func (cc CachedConn) GetRedis() kv.Store

store operate redis

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) QueryRowAllOne

func (cc CachedConn) QueryRowAllOne(v any, key string, query QueryAllOneFnx) error

QueryRowx unmarshals into v with given key and query func.

func (CachedConn) QueryRowAllOneCtx

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

QueryRowxCtx unmarshals into v with given key and query func.

func (CachedConn) QueryRowCtx

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) error

QueryRowIndex unmarshals into v with given key.

func (CachedConn) QueryRowIndexCtx

func (cc CachedConn) QueryRowIndexCtx(ctx context.Context, v any, key string,
	keyer func(primary any) string, indexQuery IndexQueryCtxFn,
	primaryQuery PrimaryQueryCtxFn) error

QueryRowIndexCtx unmarshals into v with given key.

func (CachedConn) QueryRowNoCache

func (cc CachedConn) QueryRowNoCache(v any, q string, args ...any) error

QueryRowNoCache unmarshals into v with given statement.

func (CachedConn) QueryRowNoCacheCtx

func (cc CachedConn) QueryRowNoCacheCtx(ctx context.Context, v any, q string,
	args ...any) error

QueryRowNoCacheCtx unmarshals into v with given statement.

func (CachedConn) QueryRowsNoCache

func (cc CachedConn) QueryRowsNoCache(v any, q string, args ...any) error

QueryRowsNoCache unmarshals into v with given statement. It doesn't use cache, because it might cause consistency problem.

func (CachedConn) QueryRowsNoCacheCtx

func (cc CachedConn) QueryRowsNoCacheCtx(ctx context.Context, v any, q string,
	args ...any) error

QueryRowsNoCacheCtx unmarshals into v with given statement. It doesn't use cache, because it might cause consistency problem.

func (CachedConn) QueryRowx

func (cc CachedConn) QueryRowx(v any, key, field string, query QueryFnx) error

QueryRowx unmarshals into v with given key and query func.

func (CachedConn) QueryRowxCtx

func (cc CachedConn) QueryRowxCtx(ctx context.Context, v any, key, field string, query QueryCtxFnx) error

QueryRowxCtx unmarshals into v with given key and query func.

func (CachedConn) Redis

func (cc CachedConn) Redis(key string) (*redis.Redis, error)

Redis with key

func (CachedConn) SetCache

func (cc CachedConn) SetCache(key string, val any) error

SetCache sets v into cache with given key.

func (CachedConn) SetCacheCtx

func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val any) error

SetCacheCtx sets v into cache with given key.

func (CachedConn) Transact

func (cc CachedConn) Transact(fn func(sqlx.Session) error) error

Transact runs given fn in transaction mode.

func (CachedConn) TransactCtx

func (cc CachedConn) TransactCtx(ctx context.Context, fn func(context.Context, cache.Cache, sqlx.Session) error) error

TransactCtx runs given fn in transaction mode.

type ExecCtxFn

type ExecCtxFn func(ctx context.Context, conn sqlx.SqlConn) (sql.Result, error)

ExecCtxFn defines the sql exec method.

type ExecFn

type ExecFn func(conn sqlx.SqlConn) (sql.Result, error)

ExecFn defines the sql exec method.

type ExecxCtxFn

type ExecxCtxFn func(ctx context.Context, conn sqlx.SqlConn, fields ...string) (sql.Result, error)

ExecxCtxFn defines the sql exec method.

type ExecxFn

type ExecxFn func(conn sqlx.SqlConn, fields ...string) (sql.Result, error)

ExecFn defines the sql exec method.

type IndexQueryCtxFn

type IndexQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v any) (any, error)

IndexQueryCtxFn defines the query method that based on unique indexes.

type IndexQueryFn

type IndexQueryFn func(conn sqlx.SqlConn, v any) (any, error)

IndexQueryFn defines the query method that based on unique indexes.

type PrimaryQueryCtxFn

type PrimaryQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v, primary any) error

PrimaryQueryCtxFn defines the query method that based on primary keys.

type PrimaryQueryFn

type PrimaryQueryFn func(conn sqlx.SqlConn, v, primary any) error

PrimaryQueryFn defines the query method that based on primary keys.

type QueryAllOneCtxFnx

type QueryAllOneCtxFnx func(ctx context.Context, conn sqlx.SqlConn, v any, fields ...string) error

QueryAllOneCtxFnx defines the query method for table fields.

type QueryAllOneFnx

type QueryAllOneFnx func(conn sqlx.SqlConn, v any, fields ...string) error

QueryAllOneFnx defines the query method for table field.

type QueryCtxFn

type QueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v any) error

QueryCtxFn defines the query method.

type QueryCtxFnx

type QueryCtxFnx func(ctx context.Context, conn sqlx.SqlConn, v any, field string) error

QueryCtxFnx defines the query method for table field.

type QueryFn

type QueryFn func(conn sqlx.SqlConn, v any) error

QueryFn defines the query method.

type QueryFnx

type QueryFnx func(conn sqlx.SqlConn, v any, field string) error

QueryFnx defines the query method for table field.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL