Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement redis caching actor #4

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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"
    }
  ]
}

server/src/actors/room_manager_actor.rs Outdated Show resolved Hide resolved
@@ -13,6 +13,17 @@ pub struct QueryString {
name: String,
}

#[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