Brendan Vanous
started a topic on Thu, 25 June 2015 at 1:20 AM
Question from a user:
I want to store stats for each session in a "SessionStats" Key, but it's a complex set of values. What's the best approach for this?
Brendan Vanous
started a topic on Thu, 25 June 2015 at 1:20 AM
Question from a user:
I want to store stats for each session in a "SessionStats" Key, but it's a complex set of values. What's the best approach for this?
Best Answer
Brendan Vanous said on Thu, 25 June 2015 at 1:21 AM
The simplest would be to make the Value embedded JSON, using parse to read it from the Value string, and stringify to write it out for storage. One problem with that is that the Values are limited to 128KB - which would mean a lot of sessions in all likelihood, but you wouldn't want to run out of space.
Here are a couple of other ways you could implement this in our current system:
For each play session, create a single Key which contains all the elements for the session as encoded JSON. The Key for each session Key could be a consistent identifier plus a unique identifier, like a datestamp or GUID, like so: "SessionStats_20150625145628000" (2015.06.25 at 14:56:28.000). You can then get all Keys for the user and use those with "SessionStats" prefix.
Use a Shared Group Data object to specifically hold all the stats for the player sessions. You could create it with the SharedGroupId "SessionStats_[PlayFabId]" (substituting the actual PlayFab ID for the user for [PlayFabId]), and then store the sessions each with a Key being a timestamp or GUID. You can then query all the Keys from the Shared Group Data object in one call. If you don't want the player to be able to modify the values (a hacked client, for example), you would want to make sure that you don't add the player to the Shared Group Data object, and only read/write it via Cloud Script.
Brendan
1 Comment
Brendan Vanous said on Thu, 25 June 2015 at 1:21 AM
The simplest would be to make the Value embedded JSON, using parse to read it from the Value string, and stringify to write it out for storage. One problem with that is that the Values are limited to 128KB - which would mean a lot of sessions in all likelihood, but you wouldn't want to run out of space.
Here are a couple of other ways you could implement this in our current system:
For each play session, create a single Key which contains all the elements for the session as encoded JSON. The Key for each session Key could be a consistent identifier plus a unique identifier, like a datestamp or GUID, like so: "SessionStats_20150625145628000" (2015.06.25 at 14:56:28.000). You can then get all Keys for the user and use those with "SessionStats" prefix.
Use a Shared Group Data object to specifically hold all the stats for the player sessions. You could create it with the SharedGroupId "SessionStats_[PlayFabId]" (substituting the actual PlayFab ID for the user for [PlayFabId]), and then store the sessions each with a Key being a timestamp or GUID. You can then query all the Keys from the Shared Group Data object in one call. If you don't want the player to be able to modify the values (a hacked client, for example), you would want to make sure that you don't add the player to the Shared Group Data object, and only read/write it via Cloud Script.
Brendan
No one has followed this question yet.