Closed SeaRoth closed 7 years ago
Hello again @SeaRoth,
regarding the closed issue (#3) - the information in there is already outdated, now all you need to do in order to enable rate limiting is to provide RiotAPI::SET_CACHE_RATELIMIT
option with true
value when initializing the library. That's how easy it is now, the process is fully automatic and you do not need to provide the limits by yourself anymore.
For further info on rate limiting, please visit wiki pages.
And the caching - that's more like about what you would prefer. If you'd like some sort of SQL cache provider, you will have to implement it by yourself (because I did not make one). But if you are using Laravel, then, I guess you can use xKairu's cache provider for Laravel. For further info on caching providers, please visit wiki pages.
Regarding the match data, Match resource
is not really suitable for call caching, library would cache match endpoints for each match but it would also cache matchlist endpoints, which would prevent you from accessing new matches from match history.
For this purpose, saving the data to database is probably the best option.
If you've got any more questions or if anything from what I've explained is still unclear, feel completly free to reply anytime or to close the issue 😼
Ello M8!
Ok I'm gonna go into uncharted territory and get this SQL caching (or a json version) to work and hopefully contribute.
While testing your own app - it's SO easy to exceed the rate limits:
Have you ran into such a problem? How did you get around it?
Do you have a league app? A: I kind of do have, but I am only using tournament endpoints, so I do not actually need to cache anything. I do not need to work with match history of the player, BUT I am saving the match data in my database, when the game ends.
How do you prevent the app from requesting the same info over and over (e.g. match DTO, static champion data)? A: You can prevent it by enabling the call caching feature and letting it build the cache. When you submit your app, and get approved, your API key rate limits will be lifted and you will have a lot more requests to work with.
What if you go over the rate limit, do you tell the user to wait 10 seconds and try again? Do you add a loading gif and tell the users to wait while it finishes? A: Yeah, probably, there is not really another way around it, just use this:
// ...
try {
$api->getMatch(...);
}
catch (ServerLimitException $ex) {
// Ratelimit exceeded, handle this state
}
// ...
While testing your own app - it's SO easy to exceed the rate limits A: Yeah, I know about these, but its important to know, that there are two limits in place:
Method limits were recently introduced to the StaticData resource, and they are VERY strict in comparison to the limits for other endpoints. For further information on rate limiting and rate limits itself, you can visit official Riot developer pages.
How to get around these... you need to use cache. TIP - method rate limits are not region enforced, which means when you deplete method rate limit on EUNE, you can continue on EUW, TR, NA, etc. (you can use this workaround when fetching previously mentioned StaticData, but obviously not when trying to get someones matchhistory).
Please pardon my noobness,
I was reading this closed bug and trying to grasp how to do rate limits and caching calls but I'm just completely lost.
Do I need to make my own cache provider class that connects to my database and then uploads / retrieves the data from there? Should I follow this to set it up? Should I just copy/pasta xKairu's ICacheProvider?
I'm about to implement the next level to my app which will make 10-20 requests for the match data and I neither want to go over the rate limit nor do I want to continually ask Riot for the information when I could just as easily store it into a SQL database or where ever.