sqlc

package
v0.0.0-...-440800f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 7 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.DB, c cache.CacheConf, opts ...cache.Option) CachedConn

NewConn returns a CachedConn with a redis cluster cache.

func NewConnWithCache

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

NewConnWithCache returns a CachedConn with a custom cache.

func NewNodeConn

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

NewNodeConn returns a CachedConn with a redis node cache.

func (CachedConn) DelCache

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

DelCache deletes cache with keys.

func (CachedConn) Exec

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

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

func (CachedConn) ExecNoCache

func (cc CachedConn) ExecNoCache(ctx context.Context, q string, args ...interface{}) (
	sql.Result, error)

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

func (CachedConn) GetCache

func (cc CachedConn) GetCache(ctx context.Context, key string, v interface{}) error

GetCache unmarshals cache with given key into v.

func (CachedConn) QueryRow

func (cc CachedConn) QueryRow(ctx context.Context, v interface{}, key string, query QueryFn) error

QueryRow unmarshals into v with given key and query func.

func (CachedConn) QueryRowIndex

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

QueryRowIndex unmarshals into v with given key.

func (CachedConn) QueryRowNoCache

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

QueryRowNoCache unmarshals into v with given statement.

func (CachedConn) QueryRowsNoCache

func (cc CachedConn) QueryRowsNoCache(ctx context.Context, 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) SetCache

func (cc CachedConn) SetCache(ctx context.Context, key string, val interface{}) error

SetCache sets v into cache with given key.

func (CachedConn) Transact

func (cc CachedConn) Transact(ctx context.Context, fn func(c *sqlx.Tx) error) error

Transact runs given fn in transaction mode.

type ExecFn

type ExecFn func(ctx context.Context, conn *sqlx.DB) (sql.Result, error)

ExecFn defines the sql exec method.

type IndexQueryFn

type IndexQueryFn func(ctx context.Context, conn *sqlx.DB, v interface{}) (interface{}, error)

IndexQueryFn defines the query method that based on unique indexes.

type PrimaryQueryFn

type PrimaryQueryFn func(ctx context.Context, conn *sqlx.DB, v, primary interface{}) error

PrimaryQueryFn defines the query method that based on primary keys.

type QueryFn

type QueryFn func(ctx context.Context, conn *sqlx.DB, 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