mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 03:13:15 +08:00 
			
		
		
		
	refactor: delete message and message batch use lua.
This commit is contained in:
		
							parent
							
								
									bcf089cb07
								
							
						
					
					
						commit
						b98c54e795
					
				
							
								
								
									
										4
									
								
								pkg/common/storage/cache/redis/msg.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								pkg/common/storage/cache/redis/msg.go
									
									
									
									
										vendored
									
									
								
							@ -16,7 +16,6 @@ package redis
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"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/msgprocessor"
 | 
			
		||||
@ -72,7 +71,6 @@ func (c *msgCache) SetMessagesToCache(ctx context.Context, conversationID string
 | 
			
		||||
		var values []string
 | 
			
		||||
		for _, key := range keys {
 | 
			
		||||
			if msg, ok := msgMap[key]; ok {
 | 
			
		||||
				fmt.Print("rdb msgData is ", key, msg)
 | 
			
		||||
				s, err := msgprocessor.Pb2String(msg)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					return err
 | 
			
		||||
@ -80,7 +78,6 @@ func (c *msgCache) SetMessagesToCache(ctx context.Context, conversationID string
 | 
			
		||||
				values = append(values, s)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		fmt.Print("rdb values is ", keys, values)
 | 
			
		||||
		return LuaSetBatchWithCommonExpire(ctx, c.rdb, keys, values, msgCacheTimeout)
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -173,7 +170,6 @@ func (c *msgCache) GetMessagesBySeq(ctx context.Context, conversationID string,
 | 
			
		||||
 | 
			
		||||
			msg := &sdkws.MsgData{}
 | 
			
		||||
			msgString, ok := value.(string)
 | 
			
		||||
			fmt.Println("get result", "seq", seq, "msg string", msgString)
 | 
			
		||||
			if !ok || msgprocessor.String2Pb(msgString, msg) != nil {
 | 
			
		||||
				failedSeqs = append(failedSeqs, seq)
 | 
			
		||||
				continue
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								pkg/common/storage/cache/redis/msg_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								pkg/common/storage/cache/redis/msg_test.go
									
									
									
									
										vendored
									
									
								
							@ -66,7 +66,6 @@ func Test_msgCache_GetMessagesBySeq(t *testing.T) {
 | 
			
		||||
		seqs           []int64
 | 
			
		||||
	}
 | 
			
		||||
	var failedSeq []int64
 | 
			
		||||
	//var seqMsg []*sdkws.MsgData
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		name           string
 | 
			
		||||
		fields         fields
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user