db

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMySQL

func NewMySQL(opts *MySQLOptions) (*gorm.DB, error)

NewMySQL 使用给定的选项创建一个新的 MySQL 数据库实例.

func NewRedis

func NewRedis(opts *RedisOptions) (*redis.Client, error)

NewRedis 使用给定的选项创建一个新的 Redis 数据库实例.

Types

type MySQLOptions

type MySQLOptions struct {
	Host                  string
	Username              string
	Password              string
	Database              string
	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifeTime time.Duration
	LogLevel              int
}

MySQLOptions 定义 MySQL 数据库的选项.

func (*MySQLOptions) DSN

func (o *MySQLOptions) DSN() string

DSN 从 MySQLOptions 返回 DSN.

type RedisOptions

type RedisOptions struct {
	Host     string
	Port     int
	Username string
	Password string
	Database int
}

RedisOptions 定义 Redis 数据库的选项.

func (*RedisOptions) Addr

func (o *RedisOptions) Addr() string

Jump to

Keyboard shortcuts

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