refactor: delete message and message batch use lua.

pull/2325/head
Gordon 1 year ago
parent bcf089cb07
commit b98c54e795

@ -16,7 +16,6 @@ package redis
import ( import (
"context" "context"
"fmt"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
@ -72,7 +71,6 @@ func (c *msgCache) SetMessagesToCache(ctx context.Context, conversationID string
var values []string var values []string
for _, key := range keys { for _, key := range keys {
if msg, ok := msgMap[key]; ok { if msg, ok := msgMap[key]; ok {
fmt.Print("rdb msgData is ", key, msg)
s, err := msgprocessor.Pb2String(msg) s, err := msgprocessor.Pb2String(msg)
if err != nil { if err != nil {
return err return err
@ -80,7 +78,6 @@ func (c *msgCache) SetMessagesToCache(ctx context.Context, conversationID string
values = append(values, s) values = append(values, s)
} }
} }
fmt.Print("rdb values is ", keys, values)
return LuaSetBatchWithCommonExpire(ctx, c.rdb, keys, values, msgCacheTimeout) return LuaSetBatchWithCommonExpire(ctx, c.rdb, keys, values, msgCacheTimeout)
}) })
if err != nil { if err != nil {
@ -173,7 +170,6 @@ func (c *msgCache) GetMessagesBySeq(ctx context.Context, conversationID string,
msg := &sdkws.MsgData{} msg := &sdkws.MsgData{}
msgString, ok := value.(string) msgString, ok := value.(string)
fmt.Println("get result", "seq", seq, "msg string", msgString)
if !ok || msgprocessor.String2Pb(msgString, msg) != nil { if !ok || msgprocessor.String2Pb(msgString, msg) != nil {
failedSeqs = append(failedSeqs, seq) failedSeqs = append(failedSeqs, seq)
continue continue

@ -66,7 +66,6 @@ func Test_msgCache_GetMessagesBySeq(t *testing.T) {
seqs []int64 seqs []int64
} }
var failedSeq []int64 var failedSeq []int64
//var seqMsg []*sdkws.MsgData
tests := []struct { tests := []struct {
name string name string
fields fields fields fields

Loading…
Cancel
Save