I have run out of currencies amount limit but I still need to implement energy and regeneration logic for it. What I thought about is adding energy key to the player title data as a simple json value, writing a CloudScript that would receive players segment as an argument and then loop through all the players from that segment and add 1 to their energy value. And adding a scheduled task to run this script once per hour. Is it going to work with large amount of players (let's say 10 000 players in a segment)? Or am I going to get performance spikes or face API calls limit? How would this approach be different from using native PlayFab regeneration parameters from the Currencies tab?
And I also think that I could have a collision in this case.
For example if I have 10 points of energy and I run a level which subtracts 3 points and the abovementioned script executes at the same time and tries to restore 1 energy point, can I be sure to get 8 energy points after both of these operations are finished executing?
I fear that a situation like this could happen:
1. Energy subtraction script started, it gets current value which is 10.
2. Before subtraction script is completed, restoration script has started executing. It gets current energy value which is 10 as well.
3. If subtraction script will finish sooner, I will have 7 points, but if restoration script will finish sooner, I will have 11.
Is a situation like this could occur with a solution I have described above?