database

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMongo added in v0.1.13

func GetMongo(name string) (db *mgo.Database, put func(), err error)

GetMongo 获取一个 mongodb连接

func GetMysql

func GetMysql(name string) (db *gorm.DB, put func(), err error)

GetMysql 获取一个mysql db连接

func GetRedis

func GetRedis(name string) (db redis.Conn, put func(), err error)

GetRedis 获取一个db连接

func PutConn

func PutConn(put func())

PutConn 将连接放回连接池方法

Types

type DataBase

type DataBase interface {
	RegisterAll()
	Register(string)
	// contains filtered or unexported methods
}

func NewMongo added in v0.1.13

func NewMongo() DataBase

NewMysql 初始化mysql连接

func NewMysql

func NewMysql() DataBase

NewMysql 初始化mysql连接

func NewRedis

func NewRedis() DataBase

NewRedis 初始化 redis 连接

type MongoDB added in v0.1.13

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

func (*MongoDB) Register added in v0.1.13

func (mo *MongoDB) Register(name string)

Register 注册一个mongo配置

func (*MongoDB) RegisterAll added in v0.1.13

func (mo *MongoDB) RegisterAll()

注册所有已配置的 mongo

type MysqlDB

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

func (*MysqlDB) Register

func (my *MysqlDB) Register(name string)

NewMysql 注册一个mysql配置

func (*MysqlDB) RegisterAll

func (my *MysqlDB) RegisterAll()

注册所有已配置的mysql

type RedisDB

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

func (*RedisDB) Register

func (re *RedisDB) Register(name string)

RegisterRedis 注册一个redis配置

func (*RedisDB) RegisterAll

func (re *RedisDB) RegisterAll()

注册所有已配置的 redis

Jump to

Keyboard shortcuts

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