1
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"blazing/cool"
|
||||
|
||||
@@ -80,7 +81,7 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq)
|
||||
if logininfo != nil {
|
||||
|
||||
res.Session = blazing.NewInfoService(uint32(t.UserId)).Gensession()
|
||||
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player:%d", uint32(t1.ID)), logininfo, 0)
|
||||
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player:%d", uint32(t1.ID)), logininfo, 10*time.Minute)
|
||||
|
||||
}
|
||||
return
|
||||
|
||||
@@ -160,17 +160,6 @@ func (s *InfoService) Gensession() string {
|
||||
// // 解码UUID字符串为字节数组(32位十六进制字符串对应16字节)
|
||||
uuidBytes, _ := hex.DecodeString(uuidStr)
|
||||
|
||||
// // 将accountID转换为4字节大端序字节数组
|
||||
// accountBytes := make([]byte, 4)
|
||||
// binary.BigEndian.PutUint32(accountBytes, uint32(s.userid))
|
||||
|
||||
// // 预分配缓冲区(总长度:4+16+4=24字节),减少内存分配
|
||||
// sessionBytes := make([]byte, 0, 24)
|
||||
// sessionBytes = append(sessionBytes, accountBytes...)
|
||||
// sessionBytes = append(sessionBytes, uuidBytes...)
|
||||
// //sessionBytes = append(sessionBytes, grand.B(4)...)
|
||||
|
||||
// // 编码为十六进制字符串作为最终会话ID
|
||||
sessionID := hex.EncodeToString(uuidBytes)
|
||||
cool.CacheManager.Set(context.Background(), fmt.Sprintf("session:%d", uint32(s.userid)), sessionID, 0)
|
||||
// ///User.Store(string(uuidStr), uint32(s.userid))
|
||||
|
||||
Reference in New Issue
Block a user