cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServerKey 正在的运行服务
	ServerKey = "server_ids"

	// ServerKeyExpire 过期的运行服务
	ServerKeyExpire = "server_ids_expire"

	// ServerOverTime 运行检测超时时间(单位秒)
	ServerOverTime = 50
)
View Source
const (
	VoteUsersCache     = "talk:vote:answer-users:%s"
	VoteStatisticCache = "talk:vote:statistic:%s"
)

Variables

This section is empty.

Functions

func IsGroupRelation

func IsGroupRelation(ctx context.Context, uid, gid int) bool

func SetGroupRelation

func SetGroupRelation(ctx context.Context, uid, gid int)

Types

type ClientStorage

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

func NewClientStorage

func NewClientStorage(redis *redis.Client, config *config.Config, storage *ServerStorage) *ClientStorage

func (*ClientStorage) Bind

func (c *ClientStorage) Bind(ctx context.Context, channel string, clientId int64, uid int) error

func (*ClientStorage) Del

func (c *ClientStorage) Del(ctx context.Context, channel, fd string) error

Del 删除客户端与用户绑定关系 @params channel 渠道分组 @params fd 客户端连接ID

func (*ClientStorage) GetClientIdFromUid

func (c *ClientStorage) GetClientIdFromUid(ctx context.Context, sid, channel, cid string) (int64, error)

GetClientIdFromUid 获取客户端ID关联的用户ID @params sid 服务节点ID @params channel 渠道分组 @params cid 客户端ID

func (*ClientStorage) GetUidFromClientIds

func (c *ClientStorage) GetUidFromClientIds(ctx context.Context, sid, channel, uid string) []int64

GetUidFromClientIds 获取当前节点用户ID关联的客户端ID @params sid 服务ID @params channel 渠道分组 @params uid 用户ID

func (*ClientStorage) IsCurrentServerOnline

func (c *ClientStorage) IsCurrentServerOnline(ctx context.Context, sid, channel, uid string) bool

IsCurrentServerOnline 判断当前节点是否在线 @params sid 服务ID @params channel 渠道分组 @params uid 用户ID

func (*ClientStorage) IsOnline

func (c *ClientStorage) IsOnline(ctx context.Context, channel, uid string) bool

IsOnline 判断客户端是否在线[所有部署机器] @params channel 渠道分组 @params uid 用户ID

func (*ClientStorage) Set

func (c *ClientStorage) Set(ctx context.Context, channel string, fd string, uid int) error

Set 设置客户端与用户绑定关系 @params channel 渠道分组 @params fd 客户端连接ID @params id 用户ID

func (*ClientStorage) UnBind

func (c *ClientStorage) UnBind(ctx context.Context, channel string, clientId int64) error

type ContactRemark

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

ContactRemark 好友备注缓存

func NewContactRemark

func NewContactRemark(redis *redis.Client) *ContactRemark

func (*ContactRemark) Exist

func (c *ContactRemark) Exist(ctx context.Context, uid int) bool

func (*ContactRemark) Get

func (c *ContactRemark) Get(ctx context.Context, uid int, fid int) string

func (*ContactRemark) MGet

func (c *ContactRemark) MGet(ctx context.Context, uid int, fids []int) (map[int]string, error)

func (*ContactRemark) MSet

func (c *ContactRemark) MSet(ctx context.Context, uid int, values map[string]any) error

func (*ContactRemark) Set

func (c *ContactRemark) Set(ctx context.Context, uid int, friendId int, value string) error

type JwtTokenStorage

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

func NewTokenSessionStorage

func NewTokenSessionStorage(redis *redis.Client) *JwtTokenStorage

func (*JwtTokenStorage) IsBlackList

func (s *JwtTokenStorage) IsBlackList(ctx context.Context, token string) bool

func (*JwtTokenStorage) SetBlackList

func (s *JwtTokenStorage) SetBlackList(ctx context.Context, token string, exp time.Duration) error

type LastCacheMessage

type LastCacheMessage struct {
	Content  string `json:"content"`
	Datetime string `json:"datetime"`
}

type MessageStorage

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

func NewMessageStorage

func NewMessageStorage(rds *redis.Client) *MessageStorage

func (*MessageStorage) Get

func (m *MessageStorage) Get(ctx context.Context, talkType int, sender int, receive int) (*LastCacheMessage, error)

func (*MessageStorage) MGet

func (m *MessageStorage) MGet(ctx context.Context, fields []string) ([]*LastCacheMessage, error)

func (*MessageStorage) Set

func (m *MessageStorage) Set(ctx context.Context, talkType int, sender int, receive int, message *LastCacheMessage) error

type Relation

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

func NewRelation

func NewRelation(redis *redis.Client) *Relation

func (*Relation) BatchDelGroupRelation

func (r *Relation) BatchDelGroupRelation(ctx context.Context, uids []int, gid int)

func (*Relation) DelContactRelation

func (r *Relation) DelContactRelation(ctx context.Context, uid, uid2 int)

func (*Relation) DelGroupRelation

func (r *Relation) DelGroupRelation(ctx context.Context, uid, gid int)

func (*Relation) IsContactRelation

func (r *Relation) IsContactRelation(ctx context.Context, uid, uid2 int) error

func (*Relation) SetContactRelation

func (r *Relation) SetContactRelation(ctx context.Context, uid, uid2 int)

type RoomOption

type RoomOption struct {
	Channel  string          // 渠道分类
	RoomType consts.RoomType // 房间类型
	Number   string          // 房间号
	Sid      string          // 网关ID
	Cid      int64           // 客户端ID
}

type RoomStorage

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

func NewRoomStorage

func NewRoomStorage(redis *redis.Client) *RoomStorage

func (*RoomStorage) Add

func (r *RoomStorage) Add(ctx context.Context, opt *RoomOption) error

Add 添加房间成员

func (*RoomStorage) All

func (r *RoomStorage) All(ctx context.Context, opt *RoomOption) []int64

All 获取所有房间成员

func (*RoomStorage) BatchAdd

func (r *RoomStorage) BatchAdd(ctx context.Context, opts []*RoomOption) error

func (*RoomStorage) BatchDel

func (r *RoomStorage) BatchDel(ctx context.Context, opts []*RoomOption) error

func (*RoomStorage) Del

func (r *RoomStorage) Del(ctx context.Context, opt *RoomOption) error

Del 删除房间成员

type Sequence

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

func NewSequence

func NewSequence(redis *redis.Client) *Sequence

func (*Sequence) BatchGet

func (s *Sequence) BatchGet(ctx context.Context, userId int, receiverId int, num int64) []int64

BatchGet 批量获取消息时序ID

func (*Sequence) Get

func (s *Sequence) Get(ctx context.Context, userId int, receiverId int) int64

Get 获取消息时序ID

func (*Sequence) Name

func (s *Sequence) Name(userId int, receiverId int) string

func (*Sequence) Redis

func (s *Sequence) Redis() *redis.Client

func (*Sequence) Set

func (s *Sequence) Set(ctx context.Context, userId int, receiverId int, value int) error

Set 初始化发号器

type ServerStorage

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

func NewSidStorage

func NewSidStorage(rds *redis.Client) *ServerStorage

func (*ServerStorage) All

func (s *ServerStorage) All(ctx context.Context, status int) []string

All 获取指定状态的运行 ServerStorage status 状态[1:运行中;2:已超时;3:全部]

func (*ServerStorage) Del

func (s *ServerStorage) Del(ctx context.Context, server string) error

Del 删除指定 ServerStorage

func (*ServerStorage) DelExpireServer

func (s *ServerStorage) DelExpireServer(ctx context.Context, server string) error

func (*ServerStorage) GetExpireServerAll

func (s *ServerStorage) GetExpireServerAll(ctx context.Context) []string

func (*ServerStorage) Redis

func (s *ServerStorage) Redis() *redis.Client

func (*ServerStorage) Set

func (s *ServerStorage) Set(ctx context.Context, server string, time int64) error

Set 更新服务心跳时间

func (*ServerStorage) SetExpireServer

func (s *ServerStorage) SetExpireServer(ctx context.Context, server string) error

type UnreadStorage

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

func NewUnreadStorage

func NewUnreadStorage(rds *redis.Client) *UnreadStorage

func (*UnreadStorage) All

func (u *UnreadStorage) All(ctx context.Context, receive int) map[string]int

func (*UnreadStorage) Del

func (u *UnreadStorage) Del(ctx context.Context, mode, sender, receive int)

Del 删除消息未读数 @params mode 对话模式 1私信 2群聊 @params sender 发送者ID @params receive 接收者ID

func (*UnreadStorage) Get

func (u *UnreadStorage) Get(ctx context.Context, mode, sender, receive int) int

Get 获取消息未读数 @params mode 对话模式 1私信 2群聊 @params sender 发送者ID @params receive 接收者ID

func (*UnreadStorage) Incr

func (u *UnreadStorage) Incr(ctx context.Context, mode, sender, receive int)

Incr 消息未读数自增 @params mode 对话模式 1私信 2群聊 @params sender 发送者ID @params receive 接收者ID

func (*UnreadStorage) PipeIncr

func (u *UnreadStorage) PipeIncr(ctx context.Context, pipe redis.Pipeliner, mode, sender, receive int)

PipeIncr 消息未读数自增 @params mode 对话模式 1私信 2群聊 @params sender 发送者ID @params receive 接收者ID

func (*UnreadStorage) Reset

func (u *UnreadStorage) Reset(ctx context.Context, mode, sender, receive int)

Reset 消息未读数重置 @params mode 对话模式 1私信 2群聊 @params sender 发送者ID @params receive 接收者ID

type Vote

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

func NewVote

func NewVote(rds *redis.Client) *Vote

func (*Vote) GetVoteAnswerUser

func (t *Vote) GetVoteAnswerUser(ctx context.Context, voteId string) ([]int, error)

func (*Vote) GetVoteStatistics

func (t *Vote) GetVoteStatistics(ctx context.Context, vid string) (string, error)

func (*Vote) SetVoteAnswerUser

func (t *Vote) SetVoteAnswerUser(ctx context.Context, vid string, uids []int) error

func (*Vote) SetVoteStatistics

func (t *Vote) SetVoteStatistics(ctx context.Context, vid, value string) error

Jump to

Keyboard shortcuts

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