db

package
v0.0.0-...-ee7ecfe Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IMAGEKEY = "GSERVERKEY"
)
View Source
const (
	INFINITE = (1 << 32) * time.Second
)

Variables

This section is empty.

Functions

func CloseMysql

func CloseMysql()

func Delete

func Delete(deleteStr string, args ...interface{}) (int64, error)

删除

func GetMysql

func GetMysql() *sql.DB

获取一个mysql实例

func Insert

func Insert(insertStr string, args ...interface{}) (int64, error)

插入

func NewMysql

func NewMysql(path string)

func Query

func Query(queryStr string, args ...interface{}) (map[int]map[string]string, error)

func Update

func Update(updateStr string, args ...interface{}) (int64, error)

更新

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(redisCfg Redis) *Cache

新建redis-pool

func (*Cache) ClearAll

func (cache *Cache) ClearAll() error

清理所有缓存

func (*Cache) Decr

func (cache *Cache) Decr(key string) error

自减指定key

func (*Cache) Delete

func (cache *Cache) Delete(key string) error

删除指定key

func (*Cache) Do

func (cache *Cache) Do(commandName string, args ...interface{}) (reply interface{}, err error)

执行redis命令

func (*Cache) Get

func (cache *Cache) Get(key string) interface{}

获取指定key

func (*Cache) GetMulti

func (cache *Cache) GetMulti(keys []string) []interface{}

获取多个key

func (*Cache) Hget

func (cache *Cache) Hget(key string, filed interface{}) interface{}

获取指定key,基于hset

func (*Cache) HgetMulti

func (cache *Cache) HgetMulti(key string, fileds []interface{}) []interface{}

获取多个filed,基于hset

func (*Cache) Hset

func (cache *Cache) Hset(key string, filed interface{}, val interface{}) error

存储一对k-v,基于hset

func (*Cache) Incr

func (cache *Cache) Incr(key string) error

自增指定key

func (*Cache) IsExist

func (cache *Cache) IsExist(key string) bool

检查指定key是否存在

func (*Cache) IsExistHash

func (cache *Cache) IsExistHash(key, filed string) bool

检查指定key是否存在(hash表)

func (*Cache) Put

func (cache *Cache) Put(key string, val interface{}, timeout time.Duration) error

存储一对k-v

func (*Cache) Send

func (cache *Cache) Send(commandName string, args ...interface{}) error

send

func (*Cache) Transaction

func (cache *Cache) Transaction(check checkback, exec execback, key ...string) (code int, err error)

事务封装

type CallBack

type CallBack func() error

type Mysql

type Mysql struct {
	User         string
	Password     string
	Host         string
	Db           string
	MaxOpenConns int
	MaxIdleConns int
}

配置

type MysqlTransaction

type MysqlTransaction struct {
	SQLTX *sql.Tx
}

func Begin

func Begin() (*MysqlTransaction, error)

开启事务

func (*MysqlTransaction) Commit

func (t *MysqlTransaction) Commit() error

提交事务

func (*MysqlTransaction) Delete

func (t *MysqlTransaction) Delete(deleteStr string, args ...interface{}) (int64, error)

删除

func (*MysqlTransaction) Insert

func (t *MysqlTransaction) Insert(insertStr string, args ...interface{}) (int64, error)

插入

func (*MysqlTransaction) Query

func (t *MysqlTransaction) Query(queryStr string, args ...interface{}) (map[int]map[string]string, error)

查询

func (*MysqlTransaction) Rollback

func (t *MysqlTransaction) Rollback() error

终止事务

func (*MysqlTransaction) Update

func (t *MysqlTransaction) Update(updateStr string, args ...interface{}) (int64, error)

更新

type Redis

type Redis struct {
	MaxIdle            int
	MaxActive          int
	IdleTimeout        int
	RedisServer        string
	DialConnectTimeout int
	DialReadTimeout    int
	DialWriteTimeout   int
	Auth               string
	DbNum              int
}

type Ret

type Ret struct {
	Table string
	Type  string
	Key   interface{}
	Value interface{}
}

Jump to

Keyboard shortcuts

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