question

brendan avatar image
brendan asked

Non-Key/Value pairs in user data?

Why does this only let me save string key value pairs?

like so:

void SetUserDataString(string key, string value) 
{ 
  UpdateUserDataRequest request = new UpdateUserDataRequest() 
  { 
    Data = new Dictionary<string, string>(){ 
    {key, value} 
  } 
};


PlayFabClientAPI.UpdateUserData(request, (result) => 
{ 
  Debug.Log("Successfully updated user data"); 
  }, (error) => 
  { 
    Debug.Log("Got error setting user data Ancestor to Arthur"); 
    Debug.Log(error.ErrorDetails); 
  }); 
}

it would have been really convenient if data took floats and ints as well so i could use these the same way unity playerprefs does taking a string key and then a float or int as well as value but unfortunately it does not seem to be possible?

We currently use DynamoDB rows for User Data, so it is all stored the same way - as arbitrary string data. It's also important to note that anything less than 1000 bytes is still "costing" 1000 bytes in terms of the read/write operations, since that's the base size for an entry. So the best practice is to aggregate small data values into fewer, larger key/value pairs. We'll be updating the data system in an upcoming update to provide for more efficient use of small data values, but for now, that would be the way to go in terms of usage.

data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

We currently use DynamoDB rows for User Data, so it is all stored the same way - as arbitrary string data. It's also important to note that anything less than 1000 bytes is still "costing" 1000 bytes in terms of the read/write operations, since that's the base size for an entry. So the best practice is to aggregate small data values into fewer, larger key/value pairs. We'll be updating the data system in an upcoming update to provide for more efficient use of small data values, but for now, that would be the way to go in terms of usage.

6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

saitmonato avatar image saitmonato commented ·

right now im converting int and floats to string on save and converting them back on load

0 Likes 0 ·
saitmonato avatar image saitmonato saitmonato commented ·
0 Likes 0 ·
brendan avatar image brendan ♦♦ saitmonato commented ·

Understood. But my point is that if you're storing each individual value as a separate Key/Value pair, that's extremely inefficient. I would strongly urge you to aggregate those into fewer, larger keys.

0 Likes 0 ·
saitmonato avatar image saitmonato brendan ♦♦ commented ·

how would I go about doing that? Also is it just the storing or is the loading im doing here also bad? http://hastebin.com/ugemivubaq.cs

0 Likes 0 ·
saitmonato avatar image saitmonato commented ·

also how would i go about checking which save data(local) or on playfab server is most recent and load whichever is most recent instead and overwrite the other?

0 Likes 0 ·
brendan avatar image brendan ♦♦ saitmonato commented ·

The UserDataRecord you get back for each Key queried contains a LastUpdated parameter, which is the timestamp of when that Key was last updated in PlayFab.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]