redis_test.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. package redis
  2. import (
  3. "context"
  4. "f1-game/internal/enum"
  5. nameRedis "f1-game/internal/name/redis"
  6. "f1-game/internal/pb"
  7. "fmt"
  8. "strings"
  9. "testing"
  10. "time"
  11. clog "github.com/cherry-game/cherry/logger"
  12. cprofile "github.com/cherry-game/cherry/profile"
  13. "github.com/go-redis/redis/v8"
  14. jsoniter "github.com/json-iterator/go"
  15. )
  16. func TestMain(m *testing.M) {
  17. path := "../../../etc/profile/dev.json"
  18. _, err := cprofile.Init(path, "1")
  19. if err != nil {
  20. return
  21. }
  22. Game = newGame()
  23. Game.setKey()
  24. Game.client = newClient("test", &redis.Options{
  25. Addr: "192.168.1.232:46379",
  26. Password: "H+5QfwG0jE3C@Plvgikb",
  27. DB: 0,
  28. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  29. clog.Infof("[redisID = %s] connected!", "test")
  30. return nil
  31. },
  32. })
  33. m.Run()
  34. }
  35. func TestNew111(t *testing.T) {
  36. msg := &pb.ChatMsg{
  37. MsgID: 1000,
  38. Sender: &pb.ChatPlayer{
  39. GameNodeID: "1",
  40. PlayerID: 100000001,
  41. PlayerName: "qwqa",
  42. },
  43. SendTime: 0,
  44. Type: 0,
  45. Text: "",
  46. }
  47. str, _ := jsoniter.MarshalToString(msg)
  48. fmt.Println(str)
  49. }
  50. func TestLua1(t *testing.T) {
  51. lua := `local uid = redis.call("GET", KEYS[1])
  52. if not uid or tonumber(uid) < 1 then
  53. redis.call("SET", KEYS[1], ARGV[1])
  54. return ARGV[1]
  55. else
  56. return uid
  57. end`
  58. script := redis.NewScript(lua)
  59. rdb := newTestRedis("dev.com:6379", "z~DquqVqQbGwD78^", 1)
  60. cmd := script.Run(context.Background(), rdb, []string{"uid_1"}, 2)
  61. fmt.Println(cmd.Int())
  62. }
  63. func TestLua2(t *testing.T) {
  64. lua := `
  65. redis.call('RPUSH', KEYS[1], ARGV[1])
  66. local currentSize = redis.call('LLEN', KEYS[1])
  67. local maxSize = tonumber(ARGV[2])
  68. while currentSize > maxSize do
  69. redis.call('LPOP', KEYS[1])
  70. currentSize = currentSize - 1
  71. end
  72. return currentSize
  73. `
  74. script := redis.NewScript(lua)
  75. rdb := newTestRedis("dev.com:6379", "z~DquqVqQbGwD78^", 1)
  76. cmd := script.Run(context.Background(), rdb, []string{"queue"}, 333, 20)
  77. fmt.Println(cmd.Int())
  78. }
  79. func TestGetRedis(t *testing.T) {
  80. address := "dev.com:6379"
  81. pwd := "123456"
  82. rdb := newTestRedis(address, pwd, 5)
  83. key := "key"
  84. value := "hello world"
  85. rdb.Set(context.Background(), key, value, 10*time.Minute)
  86. }
  87. func BenchmarkRedisSet(b *testing.B) {
  88. address := "dev.com:6379"
  89. pwd := "123456"
  90. rdb := newTestRedis(address, pwd, 5)
  91. key := "key"
  92. value := "hello world"
  93. expiration := 10 * time.Minute
  94. b.ResetTimer()
  95. for i := 0; i < b.N; i++ {
  96. rdb.Set(context.Background(), key, value, expiration)
  97. }
  98. }
  99. func BenchmarkRedisGet(b *testing.B) {
  100. address := "dev.com:6379"
  101. pwd := "123456"
  102. rdb := newTestRedis(address, pwd, 5)
  103. key := "key"
  104. b.ResetTimer()
  105. for i := 0; i < b.N; i++ {
  106. rdb.Get(context.Background(), key)
  107. }
  108. }
  109. func BenchmarkRedisIncr(b *testing.B) {
  110. address := "dev.com:6379"
  111. pwd := "123456"
  112. rdb := newTestRedis(address, pwd, 5)
  113. key := "incr"
  114. b.ResetTimer()
  115. for i := 0; i < b.N; i++ {
  116. rdb.Incr(context.Background(), key)
  117. }
  118. }
  119. func newTestRedis(address, pwd string, db int) *redis.Client {
  120. rdb := redis.NewClient(&redis.Options{
  121. Addr: address,
  122. Password: pwd,
  123. DB: db,
  124. PoolSize: 32,
  125. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  126. clog.Info("connected!")
  127. return nil
  128. },
  129. })
  130. return rdb
  131. }
  132. func TestSyncUIDKey(t *testing.T) {
  133. db := 4 // 2
  134. rdb := newTestRedis("dev.com:6379", "z~DquqVqQbGwD78^", db)
  135. newKeyPattern := "center:uids:%s" // pid
  136. keyPattern := "center:uid:*"
  137. keyList, err := rdb.Keys(context.Background(), keyPattern).Result()
  138. if err != nil {
  139. return
  140. }
  141. uidMaps := map[string]map[string]string{}
  142. for _, k := range keyList {
  143. splits := strings.Split(k, ":")
  144. if len(splits) != 3 {
  145. fmt.Println("splits error")
  146. continue
  147. }
  148. kv := strings.Split(splits[2], "_")
  149. if len(kv) != 2 {
  150. fmt.Println("kv error")
  151. continue
  152. }
  153. uid, err := rdb.Get(context.Background(), k).Result()
  154. if err != nil {
  155. fmt.Println(err)
  156. continue
  157. }
  158. pid := kv[0]
  159. openID := kv[1]
  160. openMaps, found := uidMaps[pid]
  161. if !found {
  162. openMaps = map[string]string{}
  163. uidMaps[pid] = openMaps
  164. }
  165. openMaps[openID] = uid
  166. }
  167. fmt.Println(len(uidMaps))
  168. for pid, openMap := range uidMaps {
  169. fmt.Printf("pid = %s, len= %d\n", pid, len(openMap))
  170. key := fmt.Sprintf(newKeyPattern, pid)
  171. for openID, uid := range openMap {
  172. rdb.HSetNX(context.Background(), key, openID, uid)
  173. }
  174. }
  175. }
  176. func TestSyncLastLoginKey(t *testing.T) {
  177. db := 4 // 2
  178. rdb := newTestRedis("dev.com:6379", "z~DquqVqQbGwD78^", db)
  179. newKeyPattern := "center:last-login:%s" // pid
  180. keyPattern := "center:last_login:*"
  181. keyList, err := rdb.Keys(context.Background(), keyPattern).Result()
  182. if err != nil {
  183. return
  184. }
  185. fmt.Println(len(keyList))
  186. loginMaps := map[string]map[string]string{}
  187. for _, k := range keyList {
  188. splits := strings.Split(k, ":")
  189. if len(splits) != 3 {
  190. fmt.Println("splits error")
  191. continue
  192. }
  193. kv := strings.Split(splits[2], "_")
  194. if len(kv) != 2 {
  195. fmt.Println("kv error")
  196. continue
  197. }
  198. json, err := rdb.Get(context.Background(), k).Result()
  199. if err != nil {
  200. fmt.Println(err)
  201. continue
  202. }
  203. pid := kv[0]
  204. openID := kv[1]
  205. openMaps, found := loginMaps[pid]
  206. if !found {
  207. openMaps = map[string]string{}
  208. loginMaps[pid] = openMaps
  209. }
  210. openMaps[openID] = json
  211. }
  212. fmt.Println(len(loginMaps))
  213. for pid, openMap := range loginMaps {
  214. fmt.Printf("pid = %s, len= %d\n", pid, len(openMap))
  215. key := fmt.Sprintf(newKeyPattern, pid)
  216. for openID, json := range openMap {
  217. rdb.HSetNX(context.Background(), key, openID, json)
  218. }
  219. }
  220. }
  221. func TestSyncServerListKey(t *testing.T) {
  222. db := 4 // 2
  223. rdb := newTestRedis("dev.com:6379", "z~DquqVqQbGwD78^", db)
  224. newKeyPattern := "center:server-list:%s" // pid
  225. keyPattern := "center:server_list:*"
  226. keyList, err := rdb.Keys(context.Background(), keyPattern).Result()
  227. if err != nil {
  228. return
  229. }
  230. serverListMaps := map[string]string{}
  231. for _, k := range keyList {
  232. splits := strings.Split(k, ":")
  233. if len(splits) != 3 {
  234. fmt.Println("splits error")
  235. continue
  236. }
  237. json, err := rdb.Get(context.Background(), k).Result()
  238. if err != nil {
  239. fmt.Println(err)
  240. continue
  241. }
  242. pid := splits[2]
  243. serverListMaps[pid] = json
  244. }
  245. fmt.Println(len(serverListMaps))
  246. for pid, json := range serverListMaps {
  247. key := fmt.Sprintf(newKeyPattern, pid)
  248. rdb.Set(context.Background(), key, json, NoExpire)
  249. }
  250. }
  251. func TestSyncPlayer(t *testing.T) {
  252. db := 1
  253. rdb := newTestRedis("dev.com:6379", "z~DquqVqQbGwD78^", db)
  254. newKeyPattern := "cross-1:player"
  255. keyPattern := "cross-1-player-detail:*"
  256. keyList, err := rdb.Keys(context.Background(), keyPattern).Result()
  257. if err != nil {
  258. return
  259. }
  260. fmt.Println(len(keyList))
  261. for _, key := range keyList {
  262. sc := rdb.Get(context.Background(), key)
  263. if sc.Err() != nil {
  264. t.Error("read fail: ", key, sc.Err().Error())
  265. continue
  266. }
  267. ss := strings.Split(key, ":")
  268. if len(ss) < 2 {
  269. t.Error("error key: ", key)
  270. continue
  271. }
  272. ic := rdb.HSet(context.Background(), newKeyPattern, ss[1], sc.Val())
  273. if ic.Err() != nil {
  274. t.Error("write fail: ", newKeyPattern, ss[1], ic.Err().Error())
  275. }
  276. }
  277. }
  278. func TestAddChatMsg(t *testing.T) {
  279. address := "192.168.1.232:46379"
  280. pwd := "H+5QfwG0jE3C@Plvgikb"
  281. redisID := "test"
  282. options := &redis.Options{
  283. Addr: address,
  284. Password: pwd,
  285. DB: 4,
  286. PoolSize: 64,
  287. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  288. clog.Infof("[redisID = %s] connected! [address = %s]", redisID, address)
  289. return nil
  290. },
  291. }
  292. cli := newClient(redisID, options)
  293. c := newChat()
  294. c.load(cli)
  295. var (
  296. start = 30000
  297. count = start + 300
  298. )
  299. for i := start; i < count; i++ {
  300. pb := &pb.ChatMsg{
  301. MsgID: int64(i),
  302. Sender: &pb.ChatPlayer{
  303. PlayerID: int64(100000 + i),
  304. PlayerName: fmt.Sprintf("玩家_%d", i),
  305. },
  306. Type: 1,
  307. Text: fmt.Sprintf("这是测试%d", i),
  308. }
  309. c.AddMsg(enum.ChatType_Game, 1, 200, pb)
  310. }
  311. list := c.GetChatMsgs(enum.ChatType_Game, 1, 0)
  312. for _, message := range list.List {
  313. fmt.Println(message)
  314. }
  315. }
  316. func TestDelChatMsg(t *testing.T) {
  317. address := "192.168.1.232:46379"
  318. pwd := "H+5QfwG0jE3C@Plvgikb"
  319. redisID := "test_chat_redis_id"
  320. options := &redis.Options{
  321. Addr: address,
  322. Password: pwd,
  323. DB: 4,
  324. PoolSize: 64,
  325. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  326. clog.Infof("[redisID = %s] connected! [address = %s]", redisID, address)
  327. return nil
  328. },
  329. }
  330. cli := newClient(redisID, options)
  331. c := newChat()
  332. c.load(cli)
  333. c.DelMsgByMsgID(enum.ChatType_Game, 1, 10003)
  334. list := c.GetChatMsgs(enum.ChatType_Game, 1, 0)
  335. for _, message := range list.List {
  336. fmt.Println(message)
  337. }
  338. }
  339. func TestGetChatMsg(t *testing.T) {
  340. address := "192.168.1.232:46379"
  341. pwd := "H+5QfwG0jE3C@Plvgikb"
  342. redisID := "test_chat_redis_id"
  343. options := &redis.Options{
  344. Addr: address,
  345. Password: pwd,
  346. DB: 4,
  347. PoolSize: 64,
  348. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  349. clog.Infof("[redisID = %s] connected! [address = %s]", redisID, address)
  350. return nil
  351. },
  352. }
  353. cli := newClient(redisID, options)
  354. c := newChat()
  355. c.load(cli)
  356. list := c.GetChatMsgs(enum.ChatType_Game, 1, 0)
  357. for _, message := range list.List {
  358. fmt.Println(message)
  359. }
  360. }
  361. func TestPlayerData(t *testing.T) {
  362. game := newGame()
  363. game.client = newClient("test", &redis.Options{
  364. Addr: "192.168.1.232:46379",
  365. Password: "H+5QfwG0jE3C@Plvgikb",
  366. DB: 0,
  367. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  368. clog.Infof("[redisID = %s] connected!", "test")
  369. return nil
  370. },
  371. })
  372. // result := game.SavePlayerDataFields(10001, map[string]any{
  373. // nameRedis.Player_PlayerID: 10001,
  374. // nameRedis.Player_PlayerName: "玩家10001",
  375. // nameRedis.Player_LordLevel: 50,
  376. // nameRedis.Player_IconID: 1,
  377. // nameRedis.Player_FrameID: 1,
  378. // nameRedis.Player_LeagueID: 1,
  379. // nameRedis.Player_LeagueName: "联盟1",
  380. // nameRedis.Player_GameNodeID: 1,
  381. // nameRedis.Player_MapNodeID: 1,
  382. // })
  383. // fmt.Println(result)
  384. // result = game.SavePlayerDataFields(10002, map[string]any{
  385. // nameRedis.Player_PlayerID: 10002,
  386. // nameRedis.Player_PlayerName: "玩家10002",
  387. // nameRedis.Player_LordLevel: 100,
  388. // nameRedis.Player_IconID: 2,
  389. // nameRedis.Player_FrameID: 2,
  390. // nameRedis.Player_LeagueID: 2,
  391. // nameRedis.Player_LeagueName: "联盟2",
  392. // nameRedis.Player_GameNodeID: 2,
  393. // nameRedis.Player_MapNodeID: 2,
  394. // })
  395. // fmt.Println(result)
  396. // playerData := game.GetPlayerData(10001, nameRedis.PlayerChatFields...)
  397. // if playerData != nil {
  398. // fmt.Printf("playerData = %+v\n", playerData)
  399. // }
  400. // list := game.GetPlayerDataList([]int64{10001, 10002}, nameRedis.PlayerChatFields...)
  401. // fmt.Printf("list = %+v\n", list)
  402. // for _, playerData := range list {
  403. // fmt.Printf("playerData = %+v\n", playerData)
  404. // }
  405. maps := game.GetPlayerDataMap([]int64{10001, 10002, 111}, nameRedis.PlayerChatFields...)
  406. fmt.Printf("map = %+v\n", maps)
  407. // for _, playerData := range maps {
  408. // fmt.Printf("playerData = %+v\n", playerData)
  409. // }
  410. }
  411. func BenchmarkGetPlayerData(b *testing.B) {
  412. game := newGame()
  413. game.client = newClient("test", &redis.Options{
  414. Addr: "192.168.1.232:46379",
  415. Password: "H+5QfwG0jE3C@Plvgikb",
  416. DB: 0,
  417. })
  418. b.ResetTimer()
  419. for b.Loop() {
  420. game.GetPlayerData(10001, nameRedis.PlayerChatFields...)
  421. }
  422. }
  423. func BenchmarkParllelGetPlayerData(b *testing.B) {
  424. game := newGame()
  425. game.client = newClient("test", &redis.Options{
  426. Addr: "192.168.1.232:46379",
  427. Password: "H+5QfwG0jE3C@Plvgikb",
  428. DB: 0,
  429. })
  430. b.ResetTimer()
  431. b.RunParallel(func(p *testing.PB) {
  432. for p.Next() {
  433. game.GetPlayerData(10001, nameRedis.PlayerChatFields...)
  434. }
  435. })
  436. }
  437. func TestAddGroupMember(t *testing.T) {
  438. address := "192.168.1.232:46379"
  439. pwd := "H+5QfwG0jE3C@Plvgikb"
  440. redisID := "test_chat_redis_id"
  441. options := &redis.Options{
  442. Addr: address,
  443. Password: pwd,
  444. DB: 4,
  445. PoolSize: 64,
  446. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  447. clog.Infof("[redisID = %s] connected! [address = %s]", redisID, address)
  448. return nil
  449. },
  450. }
  451. cli := newClient(redisID, options)
  452. c := newChat()
  453. c.load(cli)
  454. var (
  455. start = 100000
  456. count = start + 100
  457. )
  458. for i := start; i < count; i++ {
  459. c.AddGroupMember(1, int64(i))
  460. }
  461. list, _ := c.GetGroupMembers(1)
  462. for _, message := range list {
  463. fmt.Println(message)
  464. }
  465. c.DelGroupMember(1, 100000)
  466. // c.DelAllGroupMembers(1)
  467. }
  468. func TestSavePlayerTeam(t *testing.T) {
  469. var (
  470. playerID = int64(1)
  471. teams []*pb.BattleTeam
  472. )
  473. teams = append(teams, &pb.BattleTeam{
  474. TeamID: 1,
  475. Members: map[int64]*pb.BattleTeamMember{
  476. 1: {
  477. Index: 1,
  478. HeroGUID: 1,
  479. TroopsNum: 1,
  480. TroopsLimit: 1,
  481. },
  482. },
  483. })
  484. teams = append(teams, &pb.BattleTeam{
  485. TeamID: 2,
  486. Members: map[int64]*pb.BattleTeamMember{
  487. 2: {
  488. Index: 2,
  489. HeroGUID: 2,
  490. TroopsNum: 2,
  491. TroopsLimit: 2,
  492. },
  493. },
  494. })
  495. Game.UpdatePlayerTeams(playerID, teams...)
  496. }
  497. func TestGetPlayerTeams(t *testing.T) {
  498. // teams := Game.GetPlayerTeams(1)
  499. teams := Game.GetPlayerTeamsByID(1, 1)
  500. for _, team := range teams {
  501. fmt.Println(team)
  502. }
  503. }
  504. func TestGetPlayerTeamBattleSquadParam(t *testing.T) {
  505. path := "../../../etc/profile/dhc.json"
  506. _, err := cprofile.Init(path, "4")
  507. if err != nil {
  508. clog.Errorf("[TestGetPlayerTeamBattleSquadParam] error: %v", err)
  509. return
  510. }
  511. game := newGame()
  512. client := newClient("test", &redis.Options{
  513. Addr: "192.168.1.232:46379",
  514. Password: "H+5QfwG0jE3C@Plvgikb",
  515. DB: 0,
  516. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  517. clog.Infof("[redisID = %s] connected!", "test")
  518. return nil
  519. },
  520. })
  521. game.load(client)
  522. battleTeamDataList := []*pb.BattleTeamData{
  523. {
  524. PlayerID: 1048717,
  525. TeamID: 1,
  526. TeamHeros: []int64{1048723, 1048724, 1048718},
  527. },
  528. }
  529. teams, heros := game.GetPlayerBattleData(battleTeamDataList...)
  530. for _, team := range teams {
  531. fmt.Printf("team = %+v\n", team)
  532. }
  533. for _, hero := range heros {
  534. fmt.Printf("hero = %+v\n", hero)
  535. }
  536. // teams := game.GetBatchPlayerBattleSquadParams(map[int64]int32{1048577: 1, 1048766: 1})
  537. // for playerID, team := range teams {
  538. // fmt.Printf("playerID = %d, team = %+v\n", playerID, team)
  539. // }
  540. }
  541. func TestGetPlayerHeroData(t *testing.T) {
  542. playerData, teamData, heroData := Game.GetPlayerTeamHeroData(13332255, 1, 13332256)
  543. fmt.Printf("%+v\n", playerData)
  544. fmt.Printf("%+v\n", teamData)
  545. fmt.Printf("%+v\n", heroData)
  546. }
  547. func TestDelGroupKey(t *testing.T) {
  548. path := "../../../etc/profile/dhc.json"
  549. _, err := cprofile.Init(path, "4")
  550. if err != nil {
  551. clog.Errorf("[TestDelGroupKey] error: %v", err)
  552. return
  553. }
  554. chat := newChat()
  555. client := newClient("test", &redis.Options{
  556. Addr: "192.168.1.232:46379",
  557. Password: "H+5QfwG0jE3C@Plvgikb",
  558. DB: 0,
  559. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  560. clog.Infof("[redisID = %s] connected!", "test")
  561. return nil
  562. },
  563. })
  564. chat.load(client)
  565. // chat.DelAllGroupMembers(1041)
  566. memberIDList := []int64{1048950}
  567. chat.DelGroupMember(1053, memberIDList...)
  568. }
  569. func TestPrivateMsg(t *testing.T) {
  570. path := "../../../etc/profile/dhc.json"
  571. _, err := cprofile.Init(path, "4")
  572. if err != nil {
  573. clog.Errorf("[TestDelGroupKey] error: %v", err)
  574. return
  575. }
  576. chat := newChat()
  577. client := newClient("test", &redis.Options{
  578. Addr: "192.168.1.232:46379",
  579. Password: "H+5QfwG0jE3C@Plvgikb",
  580. DB: 0,
  581. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  582. clog.Infof("[redisID = %s] connected!", "test")
  583. return nil
  584. },
  585. })
  586. chat.load(client)
  587. msg := chat.GetPrivateMsgs(1049577, 1049519, 673969073461377984)
  588. for _, message := range msg.List {
  589. fmt.Println(message)
  590. }
  591. // msg := chat.GetChatMsgList(enum.ChatType_Game, 4, 673975895220009920)
  592. // for _, message := range msg.List {
  593. // fmt.Println(message)
  594. // }
  595. }
  596. func TestExchangeLog(t *testing.T) {
  597. path := "../../../etc/profile/dhc.json"
  598. _, err := cprofile.Init(path, "4")
  599. if err != nil {
  600. clog.Errorf("[TestDelGroupKey] error: %v", err)
  601. return
  602. }
  603. game := newGame()
  604. client := newClient("test", &redis.Options{
  605. Addr: "192.168.1.232:46379",
  606. Password: "H+5QfwG0jE3C@Plvgikb",
  607. DB: 0,
  608. OnConnect: func(ctx context.Context, cn *redis.Conn) error {
  609. clog.Infof("[redisID = %s] connected!", "test")
  610. return nil
  611. },
  612. })
  613. game.load(client)
  614. logs := game.GetMapExchangeLogList("map-1", 1049577, enum.ExchangeLogType_Buy, 673986573804095553)
  615. fmt.Printf("logs len = %d \n", len(logs.List))
  616. for _, log := range logs.List {
  617. fmt.Println(log)
  618. }
  619. }