cache

package
v0.0.0-...-9a03403 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultClient = "REDIS"
View Source
const RedisRoomIDMutex = "avalon:mutex:room:%s:int64"
View Source
const RedisRoomIDShortCodeKey = "avalon:short_code:room:%s:int64"
View Source
const RedisTempAssassinKey = "avalon:cache:assassin:%s:string"
View Source
const RedisTempPickKey = "avalon:cache:pick:%s:json"
View Source
const RedisUserKey = "avalon:graphql:user:%s:json"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Close()

	GetUser(ctx context.Context, userID string) (*model.User, error)
	SetUser(ctx context.Context, user *model.User) error

	GetRoomIDByShortCode(ctx context.Context, shortCode string) (int64, error)
	SetRoomIDByShortCode(ctx context.Context, roomID int64) (string, error)
	DeleteRoomIDWithShortCode(ctx context.Context, roomID int64) error

	WaitRoomMutex(ctx context.Context, roomID int64) error
	ReleaseRoomMutex(ctx context.Context, roomID int64) error

	SetGameTempAssassinatedIDs(ctx context.Context, gameID string, userIDs []string) error
	GetGameTempAssassinatedIDs(ctx context.Context, gameID string) ([]string, error)
	DeleteGameTempAssassinatedIDs(ctx context.Context, gameID string) error

	SetMissionTempPickUserIDs(ctx context.Context, missionID string, userIDs []string) error
	GetMissionTempPickUserIDs(ctx context.Context, missionID string) ([]string, error)
	DeleteMissionTempPickUserIDs(ctx context.Context, missionID string) error
}

type RedisClient

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

func NewRedisClient

func NewRedisClient() *RedisClient

func (*RedisClient) Close

func (rc *RedisClient) Close()

func (*RedisClient) DeleteGameTempAssassinatedIDs

func (rc *RedisClient) DeleteGameTempAssassinatedIDs(ctx context.Context, gameID string) error

func (*RedisClient) DeleteMissionTempPickUserIDs

func (rc *RedisClient) DeleteMissionTempPickUserIDs(ctx context.Context, missionID string) error

func (*RedisClient) DeleteRoomIDWithShortCode

func (rc *RedisClient) DeleteRoomIDWithShortCode(ctx context.Context, roomID int64) error

func (*RedisClient) GetGameTempAssassinatedIDs

func (rc *RedisClient) GetGameTempAssassinatedIDs(ctx context.Context, gameID string) ([]string, error)

func (*RedisClient) GetMissionTempPickUserIDs

func (rc *RedisClient) GetMissionTempPickUserIDs(ctx context.Context, missionID string) ([]string, error)

func (*RedisClient) GetRoomIDByShortCode

func (rc *RedisClient) GetRoomIDByShortCode(ctx context.Context, shortCode string) (int64, error)

GetRoomIDByShortCode 通过短码获取房间 ID,没有数据时返回 0 和错误

func (*RedisClient) GetUser

func (rc *RedisClient) GetUser(ctx context.Context, userID string) (*model.User, error)

func (*RedisClient) ReleaseRoomMutex

func (rc *RedisClient) ReleaseRoomMutex(ctx context.Context, roomID int64) error

func (*RedisClient) SetGameTempAssassinatedIDs

func (rc *RedisClient) SetGameTempAssassinatedIDs(ctx context.Context, gameID string, userIDs []string) error

func (*RedisClient) SetMissionTempPickUserIDs

func (rc *RedisClient) SetMissionTempPickUserIDs(ctx context.Context, missionID string, userIDs []string) error

func (*RedisClient) SetRoomIDByShortCode

func (rc *RedisClient) SetRoomIDByShortCode(ctx context.Context, roomID int64) (string, error)

func (*RedisClient) SetUser

func (rc *RedisClient) SetUser(ctx context.Context, user *model.User) error

func (*RedisClient) WaitRoomMutex

func (rc *RedisClient) WaitRoomMutex(ctx context.Context, roomID int64) error

WaitRoomMutex 抢某个房间的信号量,用于解决 RoomUser 新增时的幻读问题

Jump to

Keyboard shortcuts

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