Open pixel-anovak opened 5 years ago
Yeah, I want to reopen this issue:
public function getLocation($ip = null)
{
// Get location data
$this->location = $this->find($ip);
// Should cache location
if ($this->shouldCache($this->location, $ip)) {
$this->getCache()->set($ip, $this->location);
}
return $this->location;
}
In the current code when $ip is not provided, it tries to cache the location with $ip as the key (which is null
). Effectively, the caching doesn't work when you don't provide $ip. In case if you work with https://github.com/swayok/alternative-laravel-cache it even leads to errors, because it expects the cache key will be always present.
I guess, you meant:
public function getLocation($ip = null)
{
// Get location data
$this->location = $this->find($ip);
// Should cache location
if ($this->shouldCache($this->location, $ip)) {
$this->getCache()->set($this->remote_ip, $this->location);
}
return $this->location;
}
GeoIP.php
Here is bugfix for not caching results properly in laravel database cache.