I have no previous experience with Redis and I am writing a simple application to get to know it better.
In my app, there is a player (with his player_id) who can play one or more game (each with its game_id), and I would like to save the player's start_date and last_played informations.
I created a registration key in Redis as a Hash, where I planned to add several <player_id_game_id> records with a JSON value of
{
"start_date": ...,
"last_played": ...
}
but I quickly ran into an issue, I can't get all the games for a single user with a Redis query (something like HGET registration 10_* to get all player 10's games)
I then switched to a player-list of games approach
{
"games":[
{
"start_date": ...,
"last_played": ...
},
{
"start_date": ...,
"last_played": ...
}...
]
}
so that a HGET registration 10 would get me the list of all player 10's games
However this comes with the awareness that each update operation requires me to get the list from Redis, modify it and then update the record in Redis, and I am worried about the performances with a larger volume of data and/or operations.
Is this a good approach, or are there better ways? I don't care about the specific implementation of this sample application (eg. it's not important to have the data stored as JSON), but rather the "correct" (or best) design for a similar case.
Thanks in advance.