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 = "server_ids"

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

	//   运行检测超时时间(单位秒)
	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 CaptchaStorage

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

func NewCaptchaStorage

func NewCaptchaStorage(redis *redis.Client) *CaptchaStorage

func (*CaptchaStorage) Get

func (c *CaptchaStorage) Get(id string, clear bool) string

func (*CaptchaStorage) Set

func (c *CaptchaStorage) Set(id string, value string) error

func (*CaptchaStorage) Verify

func (c *CaptchaStorage) Verify(id, answer string, clear bool) bool

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
}

好友备注缓存

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 EmailStorage

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

func NewEmailStorage

func NewEmailStorage(redis *redis.Client) *EmailStorage

func (*EmailStorage) Del

func (s *EmailStorage) Del(ctx context.Context, channel string, email string) error

func (*EmailStorage) Get

func (s *EmailStorage) Get(ctx context.Context, channel string, email string) (string, error)

func (*EmailStorage) Set

func (s *EmailStorage) Set(ctx context.Context, channel string, email string, code string, exp time.Duration) error

func (*EmailStorage) Verify

func (s *EmailStorage) Verify(ctx context.Context, channel string, email string, code string) (pass bool)

type GroupApplyStorage

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

func NewGroupApplyStorage

func NewGroupApplyStorage(rds *redis.Client) *GroupApplyStorage

func (*GroupApplyStorage) Del

func (g *GroupApplyStorage) Del(ctx context.Context, uid int)

func (*GroupApplyStorage) Get

func (g *GroupApplyStorage) Get(ctx context.Context, uid int) int

func (*GroupApplyStorage) Incr

func (g *GroupApplyStorage) Incr(ctx context.Context, uid int)

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 RedisLock

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

func NewRedisLock

func NewRedisLock(rds *redis.Client) *RedisLock

func (*RedisLock) Lock

func (r *RedisLock) Lock(ctx context.Context, name string, expire int) bool

获取 redis 锁

func (*RedisLock) UnLock

func (r *RedisLock) UnLock(ctx context.Context, name string) bool

释放 redis 锁

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

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

func (*ServerStorage) Del

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

删除指定 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

更新服务心跳时间

func (*ServerStorage) SetExpireServer

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

type SmsStorage

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

func NewSmsStorage

func NewSmsStorage(redis *redis.Client) *SmsStorage

func (*SmsStorage) Del

func (s *SmsStorage) Del(ctx context.Context, channel string, mobile string) error

func (*SmsStorage) Get

func (s *SmsStorage) Get(ctx context.Context, channel string, mobile string) (string, error)

func (*SmsStorage) Set

func (s *SmsStorage) Set(ctx context.Context, channel string, mobile string, code string, exp time.Duration) error

func (*SmsStorage) Verify

func (s *SmsStorage) Verify(ctx context.Context, channel string, mobile string, code string) (pass bool)

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