Why is it advised to cache getBudget()?

54 views Asked by At

I've seen a slide which advises to cache with a dictionary. In which case we can even get the same budget twice? What does it save?

enter image description here

The API docs state that:

getBudget()
Returns the budget of the campaign. In order to change the campaign's budget, 
1

There are 1 answers

0
dorian On

The map isn't used to cache the budgets, it's to avoid doubling the same budget more than once.

If you were to remove that part of the code, a budget that is shared by multiple campaigns would be doubled the number of times it is used in an individual campaign (e.g. if a budget is used in 3 campaigns, it would be increased eightfold after you run the script).