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 ...any) (sql.Result, error)
- func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, q string, args ...any) (sql.Result, error)
- func (cc CachedConn) GetCache(key string, v any) error
- func (cc CachedConn) GetCacheCtx(ctx context.Context, key string, v any) error
- func (cc CachedConn) QueryRow(v any, key string, query QueryFn) error
- func (cc CachedConn) QueryRowCtx(ctx context.Context, v any, key string, query QueryCtxFn) error
- func (cc CachedConn) QueryRowIndex(v any, key string, keyer func(primary any) string, indexQuery IndexQueryFn, ...) error
- func (cc CachedConn) QueryRowIndexCtx(ctx context.Context, v any, key string, keyer func(primary any) string, ...) error
- func (cc CachedConn) QueryRowNoCache(v any, q string, args ...any) error
- func (cc CachedConn) QueryRowNoCacheCtx(ctx context.Context, v any, q string, args ...any) error
- func (cc CachedConn) QueryRowPartialNoCache(v any, q string, args ...any) error
- func (cc CachedConn) QueryRowPartialNoCacheCtx(ctx context.Context, v any, q string, args ...any) error
- func (cc CachedConn) QueryRowsNoCache(v any, q string, args ...any) error
- func (cc CachedConn) QueryRowsNoCacheCtx(ctx context.Context, v any, q string, args ...any) error
- func (cc CachedConn) QueryRowsPartialNoCache(v any, q string, args ...any) error
- func (cc CachedConn) QueryRowsPartialNoCacheCtx(ctx context.Context, v any, q string, args ...any) error
- func (cc CachedConn) SetCache(key string, val any) error
- func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val any) error
- func (cc CachedConn) SetCacheWithExpire(key string, val any, expire time.Duration) error
- func (cc CachedConn) SetCacheWithExpireCtx(ctx context.Context, key string, val any, expire time.Duration) 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
- func (cc CachedConn) WithSession(session sqlx.Session) CachedConn
- 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 ¶ added in v1.3.1
func (cc CachedConn) DelCacheCtx(ctx context.Context, keys ...string) error
DelCacheCtx deletes cache with keys.
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. If DB operation succeeds, it will delete cache with given keys, if DB operation fails, it will return nil result and non-nil error, if DB operation succeeds but cache deletion fails, it will return result and non-nil error.
func (CachedConn) ExecNoCache ¶
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 ...any) ( sql.Result, error)
ExecNoCacheCtx runs exec with given sql statement, without affecting cache.
func (CachedConn) GetCache ¶
func (cc CachedConn) GetCache(key string, v any) error
GetCache unmarshals cache with given key into v.
func (CachedConn) GetCacheCtx ¶ added in v1.3.1
GetCacheCtx unmarshals cache with given key into v.
func (CachedConn) QueryRow ¶
func (cc CachedConn) QueryRow(v any, 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 any, key string, query QueryCtxFn) error
QueryRowCtx unmarshals into v with given key and query func.
func (CachedConn) QueryRowIndex ¶
func (cc CachedConn) QueryRowIndex(v any, key string, keyer func(primary any) string, indexQuery IndexQueryFn, primaryQuery PrimaryQueryFn)