sqlc

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 6 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 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) 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) ExecNoCache

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

ExecNoCache 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) QueryRow

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

QueryRow 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) QueryRowNoCache

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

QueryRowNoCache 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) SetCache

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

SetCache 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.

type ExecFn

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

ExecFn defines the sql exec method.

type IndexQueryFn

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

IndexQueryFn defines the query method that based on unique indexes.

type PrimaryQueryFn

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

PrimaryQueryFn defines the query method that based on primary keys.

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