Documentation ¶
Index ¶
- Variables
- type CachedConn
- func (cc CachedConn) DelCache(keys ...string) error
- func (cc CachedConn) DelCacheCtx(ctx context.Context, keys ...string) error
- func (cc CachedConn) Exec(exec ExecFn, keys ...string) (sql.Result, error)
- func (cc CachedConn) ExecCtx(ctx context.Context, exec ExecCtxFn, keys ...string) (sql.Result, error)
- func (cc CachedConn) ExecNoCache(q string, args ...interface{}) (sql.Result, error)
- func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, q string, args ...interface{}) (sql.Result, error)
- func (cc CachedConn) GetCache(key string, v interface{}) error
- func (cc CachedConn) GetCacheCtx(ctx context.Context, key string, v interface{}) error
- func (cc CachedConn) QueryRow(v interface{}, key string, query QueryFn) error
- func (cc CachedConn) QueryRowCtx(ctx context.Context, v interface{}, key string, query QueryCtxFn) error
- func (cc CachedConn) QueryRowIndex(v interface{}, key string, keyer func(primary interface{}) string, ...) error
- func (cc CachedConn) QueryRowIndexCtx(ctx context.Context, v interface{}, key string, ...) error
- func (cc CachedConn) QueryRowNoCache(v interface{}, q string, args ...interface{}) error
- func (cc CachedConn) QueryRowNoCacheCtx(ctx context.Context, v interface{}, q string, args ...interface{}) error
- func (cc CachedConn) QueryRowsNoCache(v interface{}, q string, args ...interface{}) error
- func (cc CachedConn) QueryRowsNoCacheCtx(ctx context.Context, v interface{}, q string, args ...interface{}) error
- func (cc CachedConn) SetCache(key string, val interface{}) error
- func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val interface{}) error
- func (cc CachedConn) Transact(fn func(sqlx.Session) error) error
- func (cc CachedConn) TransactCtx(ctx context.Context, fn func(context.Context, sqlx.Session) error) error
- type ExecCtxFn
- type ExecFn
- type IndexQueryCtxFn
- type IndexQueryFn
- type PrimaryQueryCtxFn
- type PrimaryQueryFn
- type QueryCtxFn
- type QueryFn
Constants ¶
This section is empty.
Variables ¶
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 NewConnWithCache ¶
func NewConnWithCache(db sqlx.SqlConn, c cache.Cache) CachedConn
NewConnWithCache returns a CachedConn with a custom cache.
func NewNodeConn ¶
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) 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 ...interface{}) (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 ...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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val interface{}) error
SetCacheCtx sets v into cache with given key.
type IndexQueryCtxFn ¶
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 ¶
IndexQueryFn defines the query method that based on unique indexes.
type PrimaryQueryCtxFn ¶
PrimaryQueryCtxFn defines the query method that based on primary keys.
type PrimaryQueryFn ¶
PrimaryQueryFn defines the query method that based on primary keys.
type QueryCtxFn ¶
QueryCtxFn defines the query method.