Documentation ¶
Index ¶
- Variables
- type CachedConn
- func (cc CachedConn) DelCache(ctx context.Context, keys ...string) error
- func (cc CachedConn) Exec(ctx context.Context, exec ExecFn, keys ...string) (sql.Result, error)
- func (cc CachedConn) ExecNoCache(ctx context.Context, q string, args ...interface{}) (sql.Result, error)
- func (cc CachedConn) GetCache(ctx context.Context, key string, v interface{}) error
- func (cc CachedConn) QueryRow(ctx context.Context, v interface{}, key string, query QueryFn) error
- func (cc CachedConn) QueryRowIndex(ctx context.Context, v interface{}, key string, ...) error
- func (cc CachedConn) QueryRowNoCache(ctx context.Context, v interface{}, q string, args ...interface{}) error
- func (cc CachedConn) QueryRowsNoCache(ctx context.Context, v interface{}, q string, args ...interface{}) error
- func (cc CachedConn) SetCache(ctx context.Context, key string, val interface{}) error
- func (cc CachedConn) Transact(ctx context.Context, fn func(c *sqlx.Tx) error) error
- type ExecFn
- type IndexQueryFn
- type PrimaryQueryFn
- 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.DB, 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(ctx context.Context, keys ...string) error
DelCache deletes cache with keys.
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) 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.
type IndexQueryFn ¶
IndexQueryFn defines the query method that based on unique indexes.
type PrimaryQueryFn ¶
PrimaryQueryFn defines the query method that based on primary keys.