gstore

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

README

gstore

引入
import "github.com/layasugar/laya/gstore"
初始化各种db

Documentation

Index

Constants

View Source
const (
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
)

Variables

This section is empty.

Functions

func DbSurvive

func DbSurvive(db *gorm.DB) error

DbSurvive mysql survive

func InitDB

func InitDB(dsn string, logLevel string, DbCfgFunc ...DbConnFunc) *gorm.DB

InitDB init db

func InitRdb

func InitRdb(cfg redis.Options) *redis.Client

InitRdb 初始化redis

func RdbSurvive

func RdbSurvive(rdb *redis.Client) error

RdbSurvive redis存活检测

Types

type DbConnFunc

type DbConnFunc func(cfg *dbConfig)

func SetGormConfig

func SetGormConfig(cfg *gorm.Config) DbConnFunc

SetGormConfig set gorm config

func SetPoolConfig

func SetPoolConfig(cfg DbPoolCfg) DbConnFunc

SetPoolConfig set pool config

type DbPoolCfg

type DbPoolCfg struct {
	MaxIdleConn int `json:"max_idle_conn"` //空闲连接数
	MaxOpenConn int `json:"max_open_conn"` //最大连接数
	MaxLifeTime int `json:"max_life_time"` //连接可重用的最大时间
	MaxIdleTime int `json:"max_idle_time"` //在关闭连接之前,连接可能处于空闲状态的最大时间
}

Jump to

Keyboard shortcuts

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