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 ExecCtxFn, keys ...string) error
- func (cc CachedConn) ExecCtx(ctx context.Context, execCtx ExecCtxFn, keys ...string) error
- func (cc CachedConn) ExecNoCache(exec ExecCtxFn) error
- func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, execCtx ExecCtxFn) (err 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) QueryCtx(ctx context.Context, v interface{}, key string, query QueryCtxFn) (err error)
- func (cc CachedConn) QueryNoCacheCtx(ctx context.Context, v interface{}, query QueryCtxFn) (err 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, ...) (err error)
- func (cc CachedConn) QueryWithExpireCtx(ctx context.Context, v interface{}, key string, expire time.Duration, ...) (err error)
- func (cc CachedConn) SetCache(key string, v interface{}) error
- func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val interface{}) error
- func (cc CachedConn) SetCacheWithExpireCtx(ctx context.Context, key string, val interface{}, expire time.Duration) error
- func (cc CachedConn) Transact(fn func(db *gorm.DB) error, opts ...*sql.TxOptions) error
- func (cc CachedConn) TransactCtx(ctx context.Context, fn func(db *gorm.DB) error, opts ...*sql.TxOptions) error
- type ExecCtxFn
- type IndexQueryCtxFn
- type PrimaryQueryCtxFn
- type QueryCtxFn
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is an alias of gorm.ErrRecordNotFound. ErrNotFound = gorm.ErrRecordNotFound )
Functions ¶
This section is empty.
Types ¶
type CachedConn ¶
type CachedConn struct {
// contains filtered or unexported fields
}
func NewConnWithCache ¶
func NewConnWithCache(db *gorm.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(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) Exec ¶
func (cc CachedConn) Exec(exec ExecCtxFn, keys ...string) error
Exec runs given exec on given keys, and returns execution result.
func (CachedConn) ExecNoCache ¶
func (cc CachedConn) ExecNoCache(exec ExecCtxFn) error
ExecNoCache runs exec with given sql statement, without affecting cache.
func (CachedConn) ExecNoCacheCtx ¶
func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, execCtx ExecCtxFn) (err 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) QueryCtx ¶
func (cc CachedConn) QueryCtx(ctx context.Context, v interface{}, key string, query QueryCtxFn) (err error)
func (CachedConn) QueryNoCacheCtx ¶
func (cc CachedConn) QueryNoCacheCtx(ctx context.Context, v interface{}, query QueryCtxFn) (err error)
func (CachedConn) QueryRowIndex ¶
func (cc CachedConn) QueryRowIndex(v interface{}, key string, keyer func(primary interface{}) string, indexQuery IndexQueryCtxFn, primaryQuery PrimaryQueryCtxFn) 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) (err error)
QueryRowIndexCtx unmarshals into v with given key.
func (CachedConn) QueryWithExpireCtx ¶
func (cc CachedConn) QueryWithExpireCtx(ctx context.Context, v interface{}, key string, expire time.Duration, query QueryCtxFn) (err error)
QueryWithExpireCtx unmarshals into v with given key, set expire duration and query func.
func (CachedConn) SetCache ¶
func (cc CachedConn) SetCache(key string, v 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.
func (CachedConn) SetCacheWithExpireCtx ¶
func (cc CachedConn) SetCacheWithExpireCtx(ctx context.Context, key string, val interface{}, expire time.Duration) error
SetCacheWithExpireCtx sets v into cache with given key.
type IndexQueryCtxFn ¶
IndexQueryCtxFn defines the query method that based on unique indexes.
type PrimaryQueryCtxFn ¶
PrimaryQueryCtxFn defines the query method that based on primary keys.
type QueryCtxFn ¶
QueryCtxFn defines the query method.