Documentation ¶
Index ¶
- Constants
- Variables
- func CloseDB()
- func Execute(action Action) (obj interface{}, err error)
- func GetDB() *gorm.DB
- func GetRedisScript(cmd int) string
- func InitDB(driver, dbConnStr string)
- func InitDBForPoll(driver, dbConnStr string, maxConn int, idleConn int)
- func MapScan(r *sql.Rows, dest map[string]interface{}) error
- func NewRedisScript(commit, str string) int
- func Query(queryStr string, values ...interface{}) ([]map[string]interface{}, error)
- func QueryCount(queryStr string, values ...interface{}) (int64, error)
- func QueryForPage(pageIndex, pageSize int64, queryStr string, values ...interface{}) ([]map[string]interface{}, int64, error)
- func RedisError(err error) bool
- type Action
- type Redis
- type RedisConfig
- type RedisManager
Constants ¶
View Source
const DEFAULT_DB_DRIVER = "mysql"
View Source
const TEST_DB_DRIVER = "sqlite3"
Variables ¶
View Source
var (
ErrRedisErr = errors.New("Redis Script Error")
)
Functions ¶
func GetRedisScript ¶
func InitDBForPoll ¶
带连接池设置的DB对象
func NewRedisScript ¶
func Query ¶
Query 通用查询方法,返回[]map queryStr 查询语句 values 参数 返回值:数据集合,错误 models.Query("SELECT * FROM tablename where id = ?",2)
func QueryForPage ¶
func QueryForPage(pageIndex, pageSize int64, queryStr string, values ...interface{}) ([]map[string]interface{}, int64, error)
QueryForPage 通用分页查询方法 pageIndex 页码 pageSize 记录数 queryStr 查询语句 values 参数 返回值:数据集合,总记录数,错误 models.QueryForPage(1,10,"SELECT * FROM tablename where id = ?",2)
func RedisError ¶
Types ¶
type RedisConfig ¶
type RedisManager ¶
type RedisManager struct {
// contains filtered or unexported fields
}
func NewRedisManager ¶
func NewRedisManager(conf *RedisConfig) *RedisManager
func (*RedisManager) Add ¶
func (r *RedisManager) Add(id int, conf *RedisConfig)
func (*RedisManager) Exist ¶
func (r *RedisManager) Exist(id int) bool
func (*RedisManager) GetByRid ¶
func (r *RedisManager) GetByRid(rid int) *Redis
func (*RedisManager) GetGlobal ¶
func (r *RedisManager) GetGlobal() *Redis
func (*RedisManager) Sub ¶
func (r *RedisManager) Sub(fun func(channel, data string), channels ...string)
Click to show internal directories.
Click to hide internal directories.