Add optional cache for IP locations.#409
Conversation
|
Thanks for the PR! Though I'm not sure if I want to add this into the package itself. Developers can cache this themselves in a few lines: $ip = request()->ip();
$location = Cache::remember(
"location:{$ip}",
now()->addHour(),
fn () => Location::get($ip)
); |
Hi there. Thanks for the reply. We were using another library that had a built-in cache (using cache tags, which we learnt is very bad with the Redis backend), so I decided to implement it in yours too. A couple of included nice things is that it ignores Of course it's up to you to add it, we will continue using our fork if you don't. |
|
Sorry to ask it here, but I see you don't have discussions enabled and not sure if you'd like an issue open with feature proposals, so here it goes. We also implemented a feature that lets you download the MaxMind database in any Laravel-defined storage disk, so for example you can download it to a cloud storage bucket with the This is basically necessary on highly distributed systems, because if you run the This is all handled through config and env variables, and by default the current behaviour is untouched. I will say though, that I would strongly recommend you change the default path in the published config from using If that's something you'd be interesed in merging, I can send a PR too. |
This adds an optional cache for each IP's location, disabled by default.
New relevant config options are added for it, including LOCATION_CACHE to easily enable or disable it.