Hi!
Let me first describe the feature:
We have a leaderboard filled with data comming from GetLeaderboard.
When the user clicks on an entry we want to show a pretty complete and complex player profile, with different info that needs to be calculated from playerData, readonlyData, and statictics.
The approach would be to call a cloudscript that uses GetPlayerCombinedInfo to retrieved all needed data, processes that and returns a JSON with what we need.
This would cost some extra calls to our game, cause we have a GetPlayerCombinedInfo call made in that cloudscript each time a user wants to see a profile. That's why we are thinking of implementing a cache that holds the generated JSON for some time (each entry of the cache is valid for 5-10 minutes), so even if multiple players try to see the no.1 player, that profile gets calculated only once each 5-10 mins.
1 - How big can that cache be? Is there a limit from playfab? I couldn't find the answer in the "playfab limits" section of the docs.
2 - Is this a good solution? How are you people approaching this?
Answer by Sarah Zhang · Sep 22, 2021 at 09:43 AM
>> How big can that cache be? Is there a limit from playfab? I couldn't find the answer in the "playfab limits" section of the docs.
There is no exact limit of the data size that can be cached on CloudScript. Please follow the general limits of the CloudScript. You can navigate to your title’s [Game Manager]->[Title settings]->[Limits] or navigate to the URL - https://developer.playfab.com/en-US/c/[YourTitleId]/limits (replace the [YourTitleId] with your real title Id) to check the limits of your title.
>> Is this a good solution? How are you people approaching this?
As this thread - https://community.playfab.com/questions/15196/any-way-to-reset-all-cloudscript-instances.html said, although you can store the data as the static values to attempt to “cache” them. But since there are multiple servers that will service your CloudScript calls, each CloudScript instance will not communicate with each other, and those servers may unload your script at any time (based on overall load). We cannot guarantee that the cached value will work properly in each CloudScript API call. So, if you want to cache the data on the CloudScript, you need to implement the non-empty judgment and the retry mechanism to prevent potential problems that caused by empty data. Please check these threads for more information - https://community.playfab.com/questions/28524/cloud-script-staticvalue-to-improve-speed.html, https://community.playfab.com/questions/14498/use-of-cached-objects-in-cloudscript.html.
Besides, you can also consider caching a part of data locally to reduce the burden on the backend. Or you can use the external cache directly, such as the Azure Cache for Redis, to get a more reliable experience.
Cloudscript update multiple statistics 2 Answers
Daily, weekly and monthly leaderbord and reward player 1 Answer
Invoke Admin API from Server. 1 Answer
Playfab cloudcripts Wondering 2 Answers
"Internal Server Error" in GetFriendLeaderboard API 0 Answers