question

Kim Strasser avatar image
Kim Strasser asked

What are the costs for client/server GetUserReadOnlyData?

I often use client and server API GetUserData, GetUserReadOnlyData and GetUserInternalData. Does it make a difference in calculating the costs if I call these APIs without specifying keys?

For example, the player has 50 key/value pairs saved in Player Title Data read only. Then the player calls client or server API GetUserReadOnlyData to get only one single key/value pair:

private async Task GetUserReadOnlyData()
{
    var result = await PlayFabClientAPI.GetUserReadOnlyDataAsync(new PlayFab.ClientModels.GetUserDataRequest()
    {
        PlayFabId = PlayerPlayFabID
    });

    if (result.Error != null)
    {
      // Handle error if any
    }
    else
    {
        if (result.Result.Data == null || !result.Result.Data.ContainsKey("Country"))
            Console.WriteLine("No Country");
        else
        {
            if (result.Result.Data.ContainsKey("Country"))
                Console.WriteLine("Country: " + result.Result.Data["Country"].Value);
        }
    }
}

Does it matter if I call:

var result = await PlayFabClientAPI.GetUserReadOnlyDataAsync(new PlayFab.ClientModels.GetUserDataRequest()
    {
        PlayFabId = PlayerPlayFabID
    });

or:

var result = await PlayFabClientAPI.GetUserReadOnlyDataAsync(new PlayFab.ClientModels.GetUserDataRequest()
    {
        PlayFabId = PlayerPlayFabID
        Keys = new List<string> { "Country" }
    });

Will I have more costs if I call GetUserReadOnlyData without specifying the key?

Player 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

If you check the docs (https://docs.microsoft.com/en-us/gaming/playfab/features/pricing/meters/meters) and best practices guide (https://docs.microsoft.com/en-us/gaming/playfab/features/pricing/consumption-best-practices), you'll see that the Profile Read meter spins per KB. Unlike writes, profile reads are measured by the total amount of data returned (writes are metered per key written). So if your call returns a total of no more than 1,000 bytes, it's 1 "tick" of the meter. If it returns 50,000 bytes, that's 50 "ticks".

And as stated in the docs for all the get user data calls, "If the Keys parameter is provided, the data object returned will only contain the data specific to the indicated Keys. Otherwise, the full set of custom user data will be returned." So if you don't specify any keys, you will get all data in all the keys for that user data type.

10 |1200

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

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.