mysql

package
v0.0.0-...-e809a50 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {

	// 以下选项取值参考: https://golang.ir/pkg/database/sql/
	MaxOpenConn     int           // 默认: 128
	MaxIdleConn     int           // 默认: 8
	ConnMaxLifeTime time.Duration // 默认: 5min
	ConnMaxIdleTime time.Duration // 默认: 5min, need go 1.15 or later
	// contains filtered or unexported fields
}

Config 数据库配置

func NewConfig

func NewConfig(address, username, password, name string, opts ...Options) Config

NewConfig

func (*Config) ToDSN

func (cc *Config) ToDSN() string

ToDSN 转为dsn string

type Mutex

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

Mutex 数据库锁

func NewMutex

func NewMutex(tx **sql.Tx, table string) *Mutex

NewMutex 实例化一个数据库锁

func (*Mutex) Lock

func (m *Mutex) Lock(key string, expires time.Duration) error

Lock 上锁,异常时由 innodb_lock_wait_timeout 决定 若未超时,由事务回滚或提交决定 expires 作为数据库语句超时时间存在

func (*Mutex) Unlock

func (m *Mutex) Unlock() error

Unlock 释放锁

type Options

type Options func(*Config)

Options 数据库选项

func WithAllowAllFiles

func WithAllowAllFiles() Options

WithAllowAllFiles

func WithAllowCleartextPasswords

func WithAllowCleartextPasswords() Options

WithAllowCleartextPasswords

func WithAllowNativePasswords

func WithAllowNativePasswords() Options

WithAllowNativePasswords

func WithAllowOldPasswords

func WithAllowOldPasswords() Options

WithAllowOldPasswords

func WithCharset

func WithCharset(charset string) Options

WithCharset 设置字符集

func WithCheckConnLiveNess

func WithCheckConnLiveNess() Options

WithCheckConnLiveNess

func WithClientFoundRows

func WithClientFoundRows() Options

WithClientFoundRows

func WithCollation

func WithCollation(collation string) Options

WithCollation

func WithColumnsWithAlias

func WithColumnsWithAlias() Options

WithColumnsWithAlias

func WithConnMaxIdleTime

func WithConnMaxIdleTime(connMaxIdleTime time.Duration) Options

WithConnMaxIdleTime

func WithConnMaxLifeTime

func WithConnMaxLifeTime(connMaxLifeTime time.Duration) Options

WithConnMaxLifeTime

func WithInterpolateParams

func WithInterpolateParams() Options

WithInterpolateParams

func WithLoc

func WithLoc(loc string) Options

WithLoc 设置时区

func WithMaxAllowedPacket

func WithMaxAllowedPacket(maxAllowedPacket uint) Options

WithMaxAllowedPacket

func WithMaxIdleConn

func WithMaxIdleConn(maxIdleConn int) Options

WithMaxIdleConn

func WithMaxOpenConn

func WithMaxOpenConn(maxOpenConn int) Options

WithMaxOpenConn

func WithMultiStatements

func WithMultiStatements() Options

WithMultiStatements

func WithParseTime

func WithParseTime() Options

WithParseTime

func WithProtocol

func WithProtocol(protocol string) Options

WithProtocol 设置协议

func WithReadTimeout

func WithReadTimeout(readTimeout time.Duration) Options

WithReadTimeout

func WithRejectReadOnly

func WithRejectReadOnly() Options

WithRejectReadOnly

func WithServerPubKey

func WithServerPubKey(serverPubKey string) Options

WithServerPubKey

func WithTimeout

func WithTimeout(timeout time.Duration) Options

WithTimeout

func WithTls

func WithTls(tls string) Options

WithTls

func WithWriteTimeout

func WithWriteTimeout(writeTimeout time.Duration) Options

WithWriteTimeout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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