diff --git a/CHANGELOG.md b/CHANGELOG.md index cd600f8..df594cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to `ipinfolaravel` will be documented in this file. +## v2.1.3 + +- The IPinfo PHP SDK will no longer be initialized multiple times - one will be + initialized at application startup and used throughout. + ## v2.1.2 - Use v2.1.1 of PHP SDK (https://github.com/ipinfo/php/releases/tag/v2.1.1). diff --git a/src/ipinfolaravel.php b/src/ipinfolaravel.php index b70eefd..9042357 100644 --- a/src/ipinfolaravel.php +++ b/src/ipinfolaravel.php @@ -42,8 +42,7 @@ public function handle($request, Closure $next) if ($this->filter && call_user_func($this->filter, $request)) { $details = null; } else { - $ipinfo = new IPinfoClient($this->access_token, $this->settings); - $details = $ipinfo->getDetails($request->ip()); + $details = $this->ipinfo->getDetails($request->ip()); } $request->request->set('ipinfo', $details); @@ -70,6 +69,8 @@ public function configure() $ttl = config('services.ipinfo.cache_ttl', self::CACHE_TTL); $this->settings['cache'] = new DefaultCache($maxsize, $ttl); } + + $this->ipinfo = new IPinfoClient($this->access_token, $this->settings); } /**