sqlc

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 7 Imported by: 213

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.

func (CachedConn) ExecNoCache

func (cc CachedConn) ExecNoCache(q string, args ...interface{}) (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 ...interface{}) (
	sql.Result, error)

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

func (CachedConn) GetCache

func (cc CachedConn) GetCache(key string, v interface{}) 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 interface{}) error

GetCacheCtx unmarshals cache with given key into v.

func (CachedConn) QueryRow

func (cc CachedConn) QueryRow(v interface{}, 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 interface{}, key string, query QueryCtxFn) error

QueryRowCtx unmarshals into v with given key and query func.

func (CachedConn) QueryRowIndex

func (cc CachedConn) QueryRowIndex(v interface{}, key string, keyer func(primary interface{}) string,
	indexQuery IndexQueryFn, primaryQuery PrimaryQueryFn) error

QueryRowIndex unmarshals into v with given key.

func (CachedConn) QueryRowIndexCtx added in v1.3.1

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

QueryRowIndexCtx unmarshals into v with given key.

func (CachedConn) QueryRowNoCache

func (cc CachedConn) QueryRowNoCache(v interface{}, q string, args ...interface{}) error

QueryRowNoCache unmarshals into v with given statement.

func (CachedConn) QueryRowNoCacheCtx added in v1.3.1

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

QueryRowNoCacheCtx unmarshals into v with given statement.

func (CachedConn) QueryRowsNoCache

func (cc CachedConn) QueryRowsNoCache(v interface{}, q string, args ...interface{}) error

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

func (CachedConn) QueryRowsNoCacheCtx added in v1.3.1

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

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

func (CachedConn) SetCache

func (cc CachedConn) SetCache(key string, val interface{}) error

SetCache sets v into cache with given key.

func (CachedConn) SetCacheCtx added in v1.3.1

func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val interface{}) 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 added in v1.3.1

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

TransactCtx runs given fn in transaction mode.

type ExecCtxFn added in v1.3.1

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 IndexQueryCtxFn added in v1.3.1

type IndexQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (interface{}, error)

IndexQueryCtxFn defines the query method that based on unique indexes.

type IndexQueryFn

type IndexQueryFn func(conn sqlx.SqlConn, v interface{}) (interface{}, error)

IndexQueryFn defines the query method that based on unique indexes.

type PrimaryQueryCtxFn added in v1.3.1

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

PrimaryQueryCtxFn defines the query method that based on primary keys.

type PrimaryQueryFn

type PrimaryQueryFn func(conn sqlx.SqlConn, v, primary interface{}) error

PrimaryQueryFn defines the query method that based on primary keys.

type QueryCtxFn added in v1.3.1

type QueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error

QueryCtxFn defines the query method.

type QueryFn

type QueryFn func(conn sqlx.SqlConn, v interface{}) error

QueryFn defines the query method.

Jump to

Keyboard shortcuts

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