question

Kim Strasser avatar image
Kim Strasser asked

What is the best way to create many key/value pairs with UpdateUserReadOnlyData?

I have 40 levels in my game and I want to add 3 achievements for each level in UserReadOnlyData. The key/value pairs should be created when the player creates his account. After the player finished a level, I will check if he has reached the achievements of the current level.

I want to add the achievements(120 key/value pairs) with server API UserReadOnlyData in CloudScript:

server.UpdateUserReadOnlyData({
           PlayFabId: currentPlayerId,
           Data: {
               // Level 1 achievements:
               "Finish_level_1": "false",
               "Defeat_all_enemies": "false",
               "Minimum_obtained_points": "2000",
               // Level 2 achievements:
               "Finish_level_2": "false",
               "Minimum_collected_gems": "5",
               "Minimum_obtained_points": "3000",
               // Level 3 achievements ...
           },
           Permission: UserDataPermission.Public
        });

I found out that the limit for Player data updates per request is 10 key/value pairs in a single request. What is the best way to create the achievements in UserReadOnlyData if I cannot update more than 10 key/value pairs in a single request?

Is it necessary to make 12 request if I want to create 120 key/value pairs?

CloudScript
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

I would strongly urge you to collapse your data into fewer, larger Key/Value pairs. And some of the values above, given that they're purely numeric, might be better off as statistics.

Bear in mind that while you can write to many keys using multiple calls, each Key/Value pair write is separate in terms of how the Profile Write meter is calculated. So every Key you write to is going to tick that meter by 1, minimum (more, if the Value is more than 1,000 bytes). So writing to more Keys is going to cost you more, overall.

1 comment
10 |1200

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

Kim Strasser avatar image Kim Strasser commented ·

I'm not sure if I should create a few larger Key/Value pairs or if I should only create 1 big(less than 1000 bytes) entity object where I would save all the players achievements data.

I would always read the entity object after the player finished a level. In addition, I would update the entity object if the player reached a new achievement in the current level.

Would it be better to create 1 big entity object instead of using a few title data Key/Value pairs?

1 Like 1 ·

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.