mdb

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SET_IF_NOT_EXIST     = "NX"
	SET_WITH_EXPIRE_TIME = "PX"
)
View Source
const DEFAULT_QUEUE_NAME = "tube_queue"
View Source
const START_QUEUE_NAME = "queue_task_ids"
View Source
const TABLE_ROW_CACHE = "_tbl_row_"

Variables

View Source
var DbHandler = DbManager{}

DbHandler 数据库句柄池

View Source
var TABLE_PREFIX string

Functions

func CopyLimit added in v1.0.12

func CopyLimit(dst io.Writer, src io.Reader, length int64) (int64, error)

func InitAsyncTask added in v1.0.11

func InitAsyncTask(funMap map[string]IAsync)

func Lock

func Lock(lock_key string, request_id string, fun func())

func ParseDbConfigAndInit

func ParseDbConfigAndInit(path string) bool

func TryLock

func TryLock(lock_key string, request_id string, timeout int) bool

Types

type AsyncParams added in v1.0.11

type AsyncParams map[string]any

func (*AsyncParams) GetAny added in v1.0.11

func (p *AsyncParams) GetAny(key string) any

func (*AsyncParams) GetFloat64 added in v1.0.11

func (p *AsyncParams) GetFloat64(key string) float64

func (*AsyncParams) GetInt added in v1.0.11

func (p *AsyncParams) GetInt(key string) int

func (*AsyncParams) GetInt64 added in v1.0.11

func (p *AsyncParams) GetInt64(key string) int64

func (*AsyncParams) GetString added in v1.0.11

func (p *AsyncParams) GetString(key string) string

type Base

type Base struct {
	GetId         func() int64
	SetObjId      func(id int64)
	GetEmptyModel func() IMode
	GetSelfModel  func() IMode
	GetPInstance  func() IPagination

	Obj  MField
	Name string

	NotCache bool

	ChangeKey []string

	Tx *sql.Tx
	// contains filtered or unexported fields
}

func (*Base) AppendChangeKey

func (b *Base) AppendChangeKey(field string)

func (*Base) Delete

func (b *Base) Delete() bool

func (*Base) Exist added in v1.0.11

func (b *Base) Exist() bool

func (*Base) ExistBy added in v1.0.11

func (b *Base) ExistBy(key string, val any) bool

func (*Base) FindFirst

func (b *Base) FindFirst() bool

func (*Base) FindFirstBy

func (b *Base) FindFirstBy(key string, val any) bool

func (*Base) FindPagination

func (b *Base) FindPagination(isCount bool) any

func (*Base) GetObj

func (b *Base) GetObj() MField

func (*Base) Order

func (b *Base) Order(order string) *Base

Order 排序,如:id desc

func (*Base) Page

func (b *Base) Page(page int64) *Base

func (*Base) PageLimit

func (b *Base) PageLimit(page, pageSize int64) *Base

func (*Base) Save

func (b *Base) Save() bool

func (*Base) SetGetIdFun

func (b *Base) SetGetIdFun(f func() int64)

func (*Base) SetName

func (b *Base) SetName(name string)

func (*Base) SetObj

func (b *Base) SetObj(p MField) int

func (*Base) SetObjIdFun

func (b *Base) SetObjIdFun(f func(id int64))

func (*Base) Where

func (b *Base) Where(where string, bind ...any) *Base

func (*Base) WithCond

func (b *Base) WithCond(y def.ICond)

func (*Base) WithTx

func (b *Base) WithTx(tx *sql.Tx)

type Database

type Database struct {
	Adapter string
	User    string
	Pass    string
	Host    string
	Port    string
	Db      string
	Prefix  string
}

type DbConfig

type DbConfig struct {
	Database *Database

	Redis, Ssdb *Redis
}

type DbManager

type DbManager struct {
	Db   *sql.DB
	Rdb  *redis.Pool
	Ssdb *redis.Pool
}

func (*DbManager) Begin

func (m *DbManager) Begin(f func(tx *sql.Tx) error) error

func (*DbManager) GetRds

func (m *DbManager) GetRds(db int) redis.Conn

func (*DbManager) GetRds1 added in v1.0.11

func (m *DbManager) GetRds1() redis.Conn

func (*DbManager) GetRds2 added in v1.0.11

func (m *DbManager) GetRds2() redis.Conn

func (*DbManager) GetRds3 added in v1.0.11

func (m *DbManager) GetRds3() redis.Conn

func (*DbManager) GetRds4 added in v1.0.11

func (m *DbManager) GetRds4() redis.Conn

func (*DbManager) GetSsdb0 added in v1.0.11

func (m *DbManager) GetSsdb0() redis.Conn

func (*DbManager) InitDb

func (m *DbManager) InitDb(db *Database) error

func (*DbManager) InitRds

func (m *DbManager) InitRds(conf *Redis) bool

func (*DbManager) InitSsdb

func (m *DbManager) InitSsdb(conf *Redis) bool

type DbResult

type DbResult struct {
	Key   []string `json:"key"`
	Value []any    `json:"value"`
}

type DelayObj added in v1.0.11

type DelayObj struct {
	Name string

	Action string
	Params *AsyncParams
	// contains filtered or unexported fields
}

func (*DelayObj) Call added in v1.0.11

func (m *DelayObj) Call(action string) bool

func (*DelayObj) SetTm added in v1.0.11

func (m *DelayObj) SetTm(t ...int)

func (*DelayObj) WithParam added in v1.0.11

func (m *DelayObj) WithParam(p *AsyncParams) *DelayObj

type IAsync added in v1.0.11

type IAsync interface {
	AsyncStart(p *DelayObj)
}

type IMode

type IMode interface {
	GetObj() MField
}

type IPagination

type IPagination interface {
	SetDao(pf []any)
	SetCount(total, current, pageSize int64)
}

type MField

type MField interface {
	GetMapField() map[string]string
}

type Redis

type Redis struct {
	Host   string
	Port   string
	Db     string
	Init   int
	MaxCon int `yaml:"maxCon"`
	Idle   int
	Psw    string
}

Jump to

Keyboard shortcuts

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