Skip to content

Conversation

@haongo138
Copy link

@haongo138 haongo138 commented Dec 11, 2023

Overview

This pull request aims to integrate Redis into our application as an actor, enabling us to cache game state data for future use.

Changes

Implement a StoreActor to handle Redis GET / SET actions:

  • Persisting data:
    • Room's scoreboard (game.state.scoreboard) at game end by key room:{room_id}:scoreboard
    • Player info (api_key, team_name) on PlayerJoined message
  • An endpoint /rooms/{room_token}/scoreboard to get a finished room's scoreboard
    Example response:
  "scoreboard": [
    {
      "player_id": 0,
      "total_points": 4,
      "api_key": "player_1",
      "team_name": "player_1"
    },
    {
      "player_id": 1,
      "total_points": 1,
      "api_key": "player_0",
      "team_name": "player_0"
    }
  ]
}


#[derive(Serialize, Deserialize)]
struct ScoreboardEntry {
player_id: u32,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expose more data? how about name, sth like that. We can't show the data just the id

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I just pushed my refactor to include more info (api_key, team_name) in scoreboard response.

@haongo138 haongo138 force-pushed the feat/implement-redis-caching-actor branch from f9e0186 to 43f1268 Compare December 14, 2023 18:48
@haongo138 haongo138 requested a review from hieuphq December 15, 2023 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants