php-riot-api
php-riot-api copied to clipboard
Hardcoded CACHE_LIFETIME_MINUTES provides "Phantom Games"
Just noticed that the Hardcoding of the Cache time can be an issue when asking for an Live game, so the cache still shows the game running even tho its finished... for an whole hour...
const CACHE_LIFETIME_MINUTES_LIVE = 5;
And this are the changes to the request Function:
private function request($call, $static = false, $livematch = false)
{
if ($this->_responseCode == 200) {
if ($this->_cache !== null) {
if (!$livematch) {
$this->_cache->put($url, $result, self::CACHE_LIFETIME_MINUTES * 60);
} else {
$this->_cache->put($url, $result, self::CACHE_LIFETIME_MINUTES_LIVE * 60);
//if the request is a live match, the cache should only last for a few minutes
//else a summoner would be shown to be Ingame for another hour even tho he is done.
}
}
Maybe you can find an other more suitable solution but this is how i did it :D and it works just fine.