Documentation ¶
Index ¶
- Variables
- func IsNoRows(err error) bool
- type CacheDB
- func (c *CacheDB) CreateCacheKey(structPtr Cacheable, fields ...string) (CacheKey, reflect.Value, error)
- func (c *CacheDB) CreateCacheKeyByFields(fields []string, values []interface{}) (string, error)
- func (c *CacheDB) CreateGetQuery(whereFields ...string) string
- func (c *CacheDB) DeleteCache(structPtr Cacheable, fields ...string) error
- func (c *CacheDB) GetCache(structPtr Cacheable, fields ...string) error
- func (c *CacheDB) GetCacheByWhere(structPtr Cacheable, whereNamedCond string) error
- func (c *CacheDB) PutCache(structPtr Cacheable, fields ...string) error
- type CacheKey
- type Cacheable
- type Column
- type Config
- type DB
- func (d *DB) Callback(fn func(sqlx.DbAndTx) error, tx ...*sqlx.Tx) error
- func (d *DB) CallbackInSession(fn func(context.Context, *sqlx.Conn) error, ctx ...context.Context) error
- func (d *DB) GetCacheDB(tableName string) (*CacheDB, error)
- func (d *DB) RegisterCacheDB(ormStruct Cacheable, expire time.Duration) (*CacheDB, error)
- func (d *DB) TransactCallback(fn func(*sqlx.Tx) error, tx ...*sqlx.Tx) (err error)
- func (d *DB) TransactCallbackInSession(fn func(context.Context, *sqlx.Tx) error, ctx ...context.Context) (err error)
- type Int32s
- type Int8IFaceMap
- type IntStringMap
- type PreDB
- func (p *PreDB) InitByRdsCfg(dbConfig *Config, redisConfig *redis.Config) (err error)
- func (p *PreDB) InitByRdsClient(dbConfig *Config, redisCient *redis.Client) (err error)
- func (p *PreDB) RegisterCacheDB(ormStructPtr Cacheable, cacheExpiration time.Duration, initQuery string, ...) (*CacheDB, error)
- type Strings
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheIsNil = errors.New("*DB.Cache (redis) is nil")
ErrCacheIsNil db cache(redis) is nil
View Source
var ErrNoRows = sql.ErrNoRows
ErrNoRows no rows
Functions ¶
Types ¶
type CacheDB ¶
type CacheDB struct { *DB // contains filtered or unexported fields }
CacheDB
func (*CacheDB) CreateCacheKey ¶
func (c *CacheDB) CreateCacheKey(structPtr Cacheable, fields ...string) (CacheKey, reflect.Value, error)
CreateCacheKey create table cache key and fields values
func (*CacheDB) CreateCacheKeyByFields ¶
CreateCacheKeyByFields create cache key by fields
func (*CacheDB) CreateGetQuery ¶
CreateGetQuery get model by where fields ...
func (*CacheDB) DeleteCache ¶
DeleteCache
func (*CacheDB) GetCacheByWhere ¶
GetCacheByWhere
type CacheKey ¶
type CacheKey struct { Key string FieldValues []interface{} // contains filtered or unexported fields }
CacheKey table cache fields
type Column ¶
type Column struct { ColumnName string `json:"COLUMN_NAME" db:"COLUMN_NAME"` ColumnKey string `json:"COLUMN_KEY" db:"COLUMN_KEY"` }
Column db column
type Config ¶
type Config struct { Database string Username string Password string Host string Port int MaxIdleConns int `yaml:"max_idle_conns"` MaxOpenConns int `yaml:"max_open_conns"` // ConnMaxLifetime time: second ConnMaxLifetime int64 `yaml:"conn_max_lifetime"` // db redis cache CloseCache bool `yaml:"close_cache"` }
Config ooz mysql db config
type DB ¶
DB mysql db and cache redi.
func (*DB) CallbackInSession ¶
func (d *DB) CallbackInSession(fn func(context.Context, *sqlx.Conn) error, ctx ...context.Context) error
CallbackInSession
func (*DB) RegisterCacheDB ¶
RegisterCacheDB register a cache table.
func (*DB) TransactCallback ¶
TransactCallback
type Int32s ¶
type Int32s []int32
Int32s db column value type.
type Int8IFaceMap ¶
type Int8IFaceMap map[int8]interface{}
Int8IFaceMap db column value type.
func (*Int8IFaceMap) Scan ¶
func (i *Int8IFaceMap) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type IntStringMap ¶
IntStringMap db column value type.
func (*IntStringMap) Scan ¶
func (i *IntStringMap) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type PreDB ¶
type PreDB struct { *DB // contains filtered or unexported fields }
PreDB
func (*PreDB) InitByRdsCfg ¶
InitByRdsCfg
func (*PreDB) InitByRdsClient ¶
InitByRdsClient
Click to show internal directories.
Click to hide internal directories.