model

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IConnDB

type IConnDB interface {
	//用来执行SQL的
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type MysqlAccess

type MysqlAccess struct {
	DBConobj *sql.DB //数据库的连接池对象

	TimeZone string //数据库时区
	// contains filtered or unexported fields
}

MysqlAccess mysql连接器

func NewMysqlAccess

func NewMysqlAccess(cgmodel *MysqlConfigModel) *MysqlAccess

NewMysqlAccess 新建一个数据库管理器

func (*MysqlAccess) Close

func (access *MysqlAccess) Close()

Close 关闭池子,只有关服的时候,才会用到这个,一般不用也没有关系,也会自己关闭的

func (*MysqlAccess) GetConnBegin

func (access *MysqlAccess) GetConnBegin() *sql.Tx

GetConnBegin 拿到事件连接对象,不用的时候需要执行 Commit()或Rollback()

func (*MysqlAccess) GetDB

func (access *MysqlAccess) GetDB() *sql.DB

GetDB 拿到的并不是具体的连接,但你使用的时候,他会去池子里找个连接给你

func (*MysqlAccess) Ping

func (access *MysqlAccess) Ping() error

Ping 确认一下数据库连接

type MysqlConfigModel

type MysqlConfigModel struct {
	Dsn         string        //数据库连接字符串
	MaxOpenNum  int           //最大连接数
	MaxIdleNum  int           //最大空闲连接数
	MaxLifetime time.Duration //连接空闲等待时间(秒)
}

MysqlConfigModel 数据库地配置 下面是4种连接字符串的写法 user@unix(/path/to/socket)/dbname?charset=utf8 user:password@tcp(localhost:5555)/dbname?charset=utf8 user:password@/dbname user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname

如果是给http的服务用,建议连连数大一些,空闲也要大 如果是给专门的DB模块使用,这二个数就按你自己对应这个模块的协程数来定; 差不多1:1就可以了。

type RankInfoModel added in v1.1.3

type RankInfoModel struct {
	RankNo int          //名次
	KeyID  *util.String //名字
	Val    float64      //值
}

type ReadRow

type ReadRow struct {
	Rows    *sql.Rows
	Columns []string      //列
	Data    []interface{} //数据

}

ReadRow 行读取器

func NewRead

func NewRead(rows *sql.Rows) *ReadRow

NewRead 出一个读取器

func (*ReadRow) GetRowByColName

func (read *ReadRow) GetRowByColName(colname string) []byte

GetRowByColName 拿当前行的指定列

func (*ReadRow) Read

func (read *ReadRow) Read() bool

Read 读下一行

type RedisAccess

type RedisAccess struct {
	DBConobj *redis.Pool //redis连接池
	// contains filtered or unexported fields
}

RedisAccess redis 管理器

func NewRedisAccess

func NewRedisAccess(conf *RedisConfigModel) *RedisAccess

NewRedisAccess 生成新的管理器

func (*RedisAccess) Close

func (access *RedisAccess) Close()

Close 关闭池子,一般只有关服的时候才用到

func (*RedisAccess) GetConn

func (access *RedisAccess) GetConn() *RedisHandleModel

GetConn 拿到一个可用的连接,你要在这句之后写上:defer conn.Close() 用来在使用完之后把连接放回池子里去

type RedisConfigModel

type RedisConfigModel struct {
	ConAddr     string        //连接字符串
	MaxIdle     int           //最大的空闲连接数,表示即使没有redis连接时依然可以保持N个空闲的连接,而不被清除,随时处于待命状态
	MaxActive   int           //最大的激活连接数,表示同时最多有N个连接 ,为0事表示没有限制
	IdleTimeout time.Duration //最大的空闲连接等待时间,超过此时间后,空闲连接将被关闭(秒)
	Password    string        //连接密码

}

RedisConfigModel 配置信息

type RedisHandleModel

type RedisHandleModel struct {
	redis.Conn
}

RedisHandleModel 自己把reids的一些常用命令写在这里

func (*RedisHandleModel) DelKey

func (rd *RedisHandleModel) DelKey(dname string) (reply interface{}, err error)

DelKey 删指定的KEY

func (*RedisHandleModel) DictGet

func (rd *RedisHandleModel) DictGet(dname, key string) (reply interface{}, err error)

DictGet 读指定(字典\map)表中的指定key的值

func (*RedisHandleModel) DictGetAll

func (rd *RedisHandleModel) DictGetAll(dname string) (reply interface{}, err error)

DictGetAll 读指定字典表中的所有Key和值

func (*RedisHandleModel) DictGetAllByStringArray

func (rd *RedisHandleModel) DictGetAllByStringArray(dname string) (result []string, err error)

DictGetAllByStringArray 读指定字典表中的所有Key和值,返回[]string

func (*RedisHandleModel) DictSet

func (rd *RedisHandleModel) DictSet(dname, key string, val interface{}) (reply interface{}, err error)

DictSet 写入指定(字典\map)表中的指定的KEY,val

func (*RedisHandleModel) Dispose added in v1.1.2

func (rd *RedisHandleModel) Dispose()

func (*RedisHandleModel) Get

func (rd *RedisHandleModel) Get(key string) (reply interface{}, err error)

Get 读指定key的值

func (*RedisHandleModel) GetKeyList

func (rd *RedisHandleModel) GetKeyList(dname string) (reply interface{}, err error)

GetKeyList 返回指定KEY的列表,一般用来删除过期的KEY

func (*RedisHandleModel) ListGetArr added in v1.1.3

func (rd *RedisHandleModel) ListGetArr(rankName string, stindex, num int) ([]string, error)

List 返回指定索引范围的数据

func (*RedisHandleModel) ListLen added in v1.1.3

func (rd *RedisHandleModel) ListLen(rankName string) (int, error)

List 成员数量

func (*RedisHandleModel) ListLpush added in v1.1.3

func (rd *RedisHandleModel) ListLpush(rankName, val string) (reply interface{}, err error)

List的在尾后添加成员 "a","b" 写入"c"后为:”c“,”a“,”b“;"c"是索引0的位置

func (*RedisHandleModel) ListRpush added in v1.1.3

func (rd *RedisHandleModel) ListRpush(rankName, val string) (reply interface{}, err error)

List的在尾后添加成员 "a","b" 写入"c"后为:”a“,”b“,”c“;"a"是索引0的位置

func (*RedisHandleModel) RankAddSet added in v1.1.2

func (rd *RedisHandleModel) RankAddSet(rankName, key string, val float64) (reply interface{}, err error)

RankAddSet 累加写入排行榜数据

func (*RedisHandleModel) RankDelByKey

func (rd *RedisHandleModel) RankDelByKey(rankName, key string) (reply interface{}, err error)

RankDelByKey 删除指定排行榜中的指定key

func (*RedisHandleModel) RankGetInfo added in v1.1.3

func (rd *RedisHandleModel) RankGetInfo(rankName, key string) (result *RankInfoModel, err error)

获取排行榜从小到大的排名信息

func (*RedisHandleModel) RankGetNo added in v1.1.3

func (rd *RedisHandleModel) RankGetNo(rankName, key string) (result int, err error)

获取排名(从小到大)

func (*RedisHandleModel) RankGetPage

func (rd *RedisHandleModel) RankGetPage(rankName string, page1, page2 int) ([]*RankInfoModel, error)

RankGetPage 排行榜多少到多少 从小到大

func (*RedisHandleModel) RankGetVal added in v1.1.3

func (rd *RedisHandleModel) RankGetVal(rankName, key string) (result float64, err error)

获取指定排行榜上Key的Val

func (*RedisHandleModel) RankRevGetInfo added in v1.1.3

func (rd *RedisHandleModel) RankRevGetInfo(rankName, key string) (result *RankInfoModel, err error)

获取排行榜从大到小的排名信息

func (*RedisHandleModel) RankRevGetNo added in v1.1.3

func (rd *RedisHandleModel) RankRevGetNo(rankName, key string) (result int, err error)

获取排名(从大到小)

func (*RedisHandleModel) RankRevGetPage added in v1.1.3

func (rd *RedisHandleModel) RankRevGetPage(rankName string, page1, page2 int) ([]*RankInfoModel, error)

RankRevGetPage 排行榜多少到多少 从大到小

func (*RedisHandleModel) RankSet

func (rd *RedisHandleModel) RankSet(rankName, key string, val float64) (reply interface{}, err error)

RankGet 写入排行榜

func (*RedisHandleModel) Set

func (rd *RedisHandleModel) Set(key string, val interface{}, dt int64) (reply interface{}, err error)

Set 写入指定的KEY,val,还有时间dt;如果dt==-1,表示没有时间

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL