Browse Source

update

master
DengBiao 1 year ago
parent
commit
37c068a882
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      internal/logic/domain/group/repo/group_cache.go
  2. +3
    -3
      internal/logic/domain/group/repo/group_repo.go

+ 2
- 2
internal/logic/domain/group/repo/group_cache.go View File

@@ -32,7 +32,7 @@ func (c *groupCache) Get(groupId int64) (*model.Group, error) {
// GetLimit 获取群组缓存 // GetLimit 获取群组缓存
func (c *groupCache) GetLimit(limit string, groupId int64) (*model.Group, error) { func (c *groupCache) GetLimit(limit string, groupId int64) (*model.Group, error) {
var user model.Group var user model.Group
err := db.RedisUtil.Get(GroupKey+limit+strconv.FormatInt(groupId, 10), &user)
err := db.RedisUtil.Get(GroupKey+limit+":"+strconv.FormatInt(groupId, 10), &user)
if err != nil && err != redis.Nil { if err != nil && err != redis.Nil {
return nil, gerrors.WrapError(err) return nil, gerrors.WrapError(err)
} }
@@ -53,7 +53,7 @@ func (c *groupCache) Set(group *model.Group) error {


// SetLimit 设置群组缓存 // SetLimit 设置群组缓存
func (c *groupCache) SetLimit(limit string, group *model.Group) error { func (c *groupCache) SetLimit(limit string, group *model.Group) error {
err := db.RedisUtil.Set(GroupKey+limit+strconv.FormatInt(group.Id, 10), group, 24*time.Hour)
err := db.RedisUtil.Set(GroupKey+limit+":"+strconv.FormatInt(group.Id, 10), group, 24*time.Hour)
if err != nil { if err != nil {
return gerrors.WrapError(err) return gerrors.WrapError(err)
} }


+ 3
- 3
internal/logic/domain/group/repo/group_repo.go View File

@@ -1,8 +1,8 @@
package repo package repo


import ( import (
"gim/internal/business/comm/utils"
"gim/internal/logic/domain/group/model" "gim/internal/logic/domain/group/model"
"strconv"
) )


type groupRepo struct{} type groupRepo struct{}
@@ -38,7 +38,7 @@ func (*groupRepo) Get(groupId int64) (*model.Group, error) {


// GetLimit 获取群组信息(限量) // GetLimit 获取群组信息(限量)
func (*groupRepo) GetLimit(groupId, limit int64) (*model.Group, error) { func (*groupRepo) GetLimit(groupId, limit int64) (*model.Group, error) {
group, err := GroupCache.GetLimit(utils.Int64ToStr(limit), groupId)
group, err := GroupCache.GetLimit(strconv.FormatInt(limit, 10), groupId)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -56,7 +56,7 @@ func (*groupRepo) GetLimit(groupId, limit int64) (*model.Group, error) {
} }
group.Members = members group.Members = members


err = GroupCache.SetLimit(utils.Int64ToStr(limit), group)
err = GroupCache.SetLimit(strconv.FormatInt(limit, 10), group)
if err != nil { if err != nil {
return nil, err return nil, err
} }


Loading…
Cancel
Save