mdb

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TABLE_ROW_CACHE = "_tbl_row_"

Variables

View Source
var DbHandler = DbManager{}

DbHandler 数据库句柄池

View Source
var TABLE_PREFIX string

Functions

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 Base

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

	Obj    MField
	OutRes *bytes.Buffer
	Name   string

	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) FindFirst

func (b *Base) FindFirst() bool

func (*Base) FindFirstBy

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

func (*Base) FindPagination

func (b *Base) FindPagination() 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() *RedisInstance

func (*DbManager) GetSsdb

func (m *DbManager) GetSsdb() *RedisInstance

func (*DbManager) InitDb

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

func (*DbManager) InitRds

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

func (*DbManager) InitSsdb

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

type DbResult

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

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
	Idle   int
	Psw    string
}

type RedisInstance

type RedisInstance struct {
	Con redis.Conn
}

Jump to

Keyboard shortcuts

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