database

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlayerStatusMaxLockAliveTime = 600   // 玩家状态锁最大存活时间 秒
	MaxLockAliveTime             = 10000 // 单个锁的最大存活时间 毫秒
	LockRetryWaitTime            = 50    // 同步加锁重试间隔时间 毫秒
	MaxLockRetryTimes            = 2     // 同步加锁最大重试次数
)

Variables

View Source
var NODE *nodeStore
View Source
var PE *gorm.DB
View Source
var PlayerMailId uint32 = 100000000 // 玩家邮件ID基数

Functions

func AddAccountFieldByFieldName added in v1.3.0

func AddAccountFieldByFieldName(db *gorm.DB, account *constant.Account) (uint32, error)

添加新账号

func AddPlayerDataByUid added in v1.5.0

func AddPlayerDataByUid(db *gorm.DB, player *constant.PlayerData) error

添加新账号数据

func AddPlayerStatus added in v1.5.0

func AddPlayerStatus(rc *redis.Client, uid uint32, value []byte) bool

标记玩家状态

func AddPlayerUidByAccountId added in v1.5.0

func AddPlayerUidByAccountId(db *gorm.DB, AccountId uint32) *constant.PlayerUid

指定account id 创建数据

func DelAcceptApplyFriend added in v1.2.2

func DelAcceptApplyFriend(rc *redis.Client, db *gorm.DB, uid uint32)

删除待加入好友

func DelPlayerStatus added in v1.5.0

func DelPlayerStatus(rc *redis.Client, uid uint32)

删除玩家状态

func GetAcceptApplyFriend added in v1.2.2

func GetAcceptApplyFriend(rc *redis.Client, db *gorm.DB, uid uint32) ([]byte, bool)

获取待加入好友

func GetAccountByFieldAccountId added in v1.5.0

func GetAccountByFieldAccountId(db *gorm.DB, AccountId uint32) *constant.Account

func GetAllPlayerMail added in v1.5.0

func GetAllPlayerMail(rc *redis.Client, dsn *gorm.DB, uid uint32) map[uint32]*constant.Mail

获取玩家邮件

func GetAllRegionConf added in v1.5.0

func GetAllRegionConf(db *gorm.DB) []*constant.RegionConf

拉取全部区服配置

func GetAllRogue added in v1.3.0

func GetAllRogue(db *gorm.DB) []*constant.RogueConf

拉取全部模拟宇宙

func GetApplyFriend added in v1.5.0

func GetApplyFriend(rc *redis.Client, db *gorm.DB, uid uint32) ([]byte, bool)

获取好友申请

func GetBlockData added in v1.3.0

func GetBlockData(db *gorm.DB, uid, entryId uint32) *constant.BlockData

拉取地图文件

func GetComboTokenByAccountId added in v1.3.0

func GetComboTokenByAccountId(rc *redis.Client, db *gorm.DB, accountId uint32) string

func GetDbAllMail added in v1.3.0

func GetDbAllMail(db *gorm.DB) []*constant.Mail

拉取全部邮件

func GetPlayerBasic added in v1.5.0

func GetPlayerBasic(rc *redis.Client, db *gorm.DB, uid uint32) ([]byte, bool)

获取账号简要数据

func GetPlayerDataByUid added in v1.5.0

func GetPlayerDataByUid(db *gorm.DB, uid uint32) *constant.PlayerData

使用账号id拉取数据

func GetPlayerStatus added in v1.5.0

func GetPlayerStatus(rc *redis.Client, uid uint32) ([]byte, bool)

获取玩家状态

func GetPlayerUidByAccountId added in v1.3.0

func GetPlayerUidByAccountId(db *gorm.DB, AccountId uint32) *constant.PlayerUid

使用account id拉取数据

func GetRegionConf added in v1.5.0

func GetRegionConf(db *gorm.DB, regionName string) (*constant.RegionConf, error)

拉取区服配置

func LoginDistLockSync added in v1.5.0

func LoginDistLockSync(rc *redis.Client, accountId string) bool

DistLockSync 加锁同步阻塞直到成功或超时

func LoginDistUnlock added in v1.5.0

func LoginDistUnlock(rc *redis.Client, accountId string)

DistUnlock 解锁

func NewGameStore added in v1.5.0

func NewGameStore(mysqlList map[string]constant.MysqlConf, redisList map[string]constant.RedisConf)

func NewGateStore added in v1.5.0

func NewGateStore(mysqlList map[string]constant.MysqlConf, redisList map[string]constant.RedisConf)

func NewMysql

func NewMysql(dsn string) *gorm.DB

func NewNodeStore added in v1.5.0

func NewNodeStore(mysqlList map[string]constant.MysqlConf, redisList map[string]constant.RedisConf)

func NewPE added in v1.5.0

func NewPE(dsn string)

func NewRedis

func NewRedis(addr, password string, db int) *redis.Client

func NewSqlite added in v1.3.0

func NewSqlite(dsn string) *gorm.DB

func QueryAccountByFieldUsername added in v1.3.0

func QueryAccountByFieldUsername(db *gorm.DB, Username string) *constant.Account

查询账号

func SetAcceptApplyFriend added in v1.2.2

func SetAcceptApplyFriend(rc *redis.Client, uid uint32, value []byte) bool

设置玩家待加入数据库好友信息

func SetPlayerFriend added in v1.2.2

func SetPlayerFriend(rc *redis.Client, uid uint32, value []byte) bool

设置玩家好友申请信息

func SetRegionConf added in v1.5.0

func SetRegionConf(db *gorm.DB, regionConf *constant.RegionConf) error

设置区服数据

func UpComboTokenByAccountId added in v1.5.0

func UpComboTokenByAccountId(rc *redis.Client, db *gorm.DB, accountId uint32, comboToken string)

func UpPlayerDataByUid added in v1.5.0

func UpPlayerDataByUid(db *gorm.DB, player *constant.PlayerData) error

func UpdateAccountFieldByFieldName added in v1.3.0

func UpdateAccountFieldByFieldName(db *gorm.DB, account *constant.Account) error

更新账号

func UpdateBlockData added in v1.3.0

func UpdateBlockData(db *gorm.DB, blockData *constant.BlockData) error

更新地图文件

func UpdatePlayerBasic added in v1.3.0

func UpdatePlayerBasic(rc *redis.Client, db *gorm.DB, basic *constant.PlayerBasic) bool

更新账号简要数据

func UpdatePlayerUid added in v1.3.0

func UpdatePlayerUid(db *gorm.DB, playerUid *constant.PlayerUid) error

Types

type DisaptchStore added in v1.5.0

type DisaptchStore struct {
	AccountMysql *gorm.DB
	LoginRedis   *redis.Client
}
var DISPATCH *DisaptchStore

func NewDisaptchStore added in v1.5.0

func NewDisaptchStore(mysqlList map[string]constant.MysqlConf, redisList map[string]constant.RedisConf) *DisaptchStore

type GameStore added in v1.5.0

type GameStore struct {
	PlayerDataMysql      *gorm.DB      // 玩家数据
	ServerConf           *gorm.DB      // 服务配置
	LoginRedis           *redis.Client // 登录锁
	StatusRedis          *redis.Client // 状态锁
	PlayerBriefDataRedis *redis.Client // 玩家简要信息
	PlayerMail           *redis.Client // 玩家邮件
}
var GSS *GameStore

type GateStore added in v1.5.0

type GateStore struct {
	PlayerUidMysql *gorm.DB
	LoginRedis     *redis.Client
	StatusRedis    *redis.Client
}
var GATE *GateStore

Jump to

Keyboard shortcuts

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