Documentation ¶
Index ¶
- Constants
- Variables
- func Delete(s string, args ...interface{}) (int64, error)
- func ExecuteSQL(sqlOrArgs ...interface{}) (int64, error)
- func GetMySQLClient(c conf.MySQLConfig) *xorm.Engine
- func GetRedisClient(cfg conf.RedisConfig) *redis.Pool
- func GetRedisPool(name string) *redis.Pool
- func InitClient()
- func InitRedisPool(cfg conf.RedisConfig) *redis.Pool
- func Insert(s string, args ...interface{}) (int64, error)
- func SetRedisPool(name string, cfg conf.RedisConfig) error
- func Update(s string, args ...interface{}) (int64, error)
Constants ¶
const BasicDateFormat = "2006-01-02"
BasicDateFormat for time format layout
const BasicDatetimeFormat = "2006-01-02 15:04:05"
BasicDatetimeFormat for time format layout
const DefaultPage = 1
DefaultPage value
const DefaultPageSize = 10
DefaultPageSize value
const MaxPage = 100
MaxPage limit
const MaxPageSize = 1000
MaxPageSize limit
const StatusActive = 1
StatusActive for data status active
const StatusDelete = 0
StatusDelete for data status delete
const StatusDisable = 4
StatusDisable for data status disabled
const StatusInitialize = 0
StatusInitialize for data status init
Variables ¶
var ErrorConnNameExist = errors.New("given conn name exist")
var MySQL *xorm.Engine
MySQL client in global
var Redis *redis.Pool
Redis client in global
Functions ¶
func ExecuteSQL ¶
ExecuteSQL TL;DR return affected count
func GetMySQLClient ¶
func GetMySQLClient(c conf.MySQLConfig) *xorm.Engine
GetMySQLClient init connection once
func GetRedisClient ¶
func GetRedisClient(cfg conf.RedisConfig) *redis.Pool
GetRedisClient of redis pool
func GetRedisPool ¶ added in v1.0.11
func InitClient ¶
func InitClient()
InitClient db connections call this func after conf.Config loaded after InitClient success, db.Redis / db.MySQL can use in global context
func InitRedisPool ¶ added in v1.0.11
func InitRedisPool(cfg conf.RedisConfig) *redis.Pool
func SetRedisPool ¶ added in v1.0.11
func SetRedisPool(name string, cfg conf.RedisConfig) error
SetRedisPool @Description: this is not goroutine safe, call the func in main process @param name @param cfg @return error
Types ¶
This section is empty.