dolejska-daniel / riot-api

Riot League of Legends & DataDragon API wrappers for PHP7 and PHP8.
GNU General Public License v3.0
112 stars 25 forks source link

Multiple exceptions when caching rate limits #3

Closed kylekz closed 7 years ago

kylekz commented 7 years ago

Now I'm gonna start being a pain ;)

First error I encountered:

[2017-06-28 04:55:25] local.ERROR: ErrorException: A non well formed numeric value encountered in /Users/kyle/Code/app/vendor/dolejska-daniel/riot-api/src/RiotAPI/Definitions/RateLimitStorage.php:86

Second:

[2017-06-28 05:12:02] local.ERROR: ErrorException: Undefined index: expires in /Users/kyle/Code/app/vendor/dolejska-daniel/riot-api/src/RiotAPI/Definitions/RateLimitStorage.php:48

My API object:

$this->api = new RiotAPI([
            RiotAPI::SET_KEY => config('services.riot.key'),
            RiotAPI::SET_REGION => $this->getRegion(),
            RiotAPI::SET_CACHE_PROVIDER => IlluminateCacheProvider::class,
            RiotAPI::SET_CACHE_CALLS => true,
            RiotAPI::SET_CACHE_CALLS_LENGTH => 60,
            RiotAPI::SET_CACHE_RATELIMIT => true,
            RiotAPI::SET_RATELIMITS => [
                config('services.riot.key') => [
                    IRateLimitControl::INTERVAL_10S => 1500,
                    IRateLimitControl::INTERVAL_10M => 90000,
                    IRateLimitControl::INTERVAL_1H  => 540000,
                ],
            ],
        ]);

And because I'm using Laravel, I made an Illuminate cache provider: https://gist.github.com/xKairu/ede67698327fb722aea5e14bbd21fc68

The cache provider seems to work, as getting a stored object just after its set to $this->cache works.

Setting SET_CACHE_RATELIMIT to false results in this, and I have to remove all cache-related options to fix it:

[2017-06-28 05:14:29] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function setLimits() on null in /Users/kyle/Code/app/vendor/dolejska-daniel/riot-api/src/RiotAPI/RiotAPI.php:348
dolejska-daniel commented 7 years ago

Hi again, @xKairu!

Thank you for reporting these bugs, they should be fixed in 3bb87eb. But I'll be also making a release v0.5 containing these changes later.

Let me know if the fixes were successful 😄.

kylekz commented 7 years ago

Looks like they're successful to me, thanks!