Skip to content

Commit 3e95ab1

Browse files
committedJun 21, 2020
Fixed caching to be provider-dependent.
1 parent 2cd8813 commit 3e95ab1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [4.3.4] - 2020-06-21
66
### Fixed
77
- non-caching declaration to only apply to current query.
8+
- caching to take provider into account.
89

910
### Changed
1011
- `getProvider()` method to no longer be deprecated, and instead return the

‎src/ProviderAndDumperAggregator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function cacheRequest(string $cacheKey, array $queryElements, string $
197197
return collect($this->aggregator->{$queryType}(...$queryElements));
198198
}
199199

200-
$hashedCacheKey = sha1($cacheKey);
200+
$hashedCacheKey = sha1($this->getProvider()->getName() . "-" . $cacheKey);
201201
$duration = config("geocoder.cache.duration", 0);
202202
$store = config('geocoder.cache.store');
203203

‎tests/Feature/Providers/GeocoderServiceTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ public function testGeocoder()
160160

161161
public function testCacheIsUsed()
162162
{
163-
$cacheKey = sha1(Str::slug(strtolower(urlencode('1600 Pennsylvania Ave NW, Washington, DC 20500, USA'))));
163+
$cacheKey = sha1(
164+
app('geocoder')->getProvider()->getName()
165+
. "-" . Str::slug(strtolower(urlencode('1600 Pennsylvania Ave NW, Washington, DC 20500, USA')))
166+
);
164167

165168
$result = app('geocoder')
166169
->geocode('1600 Pennsylvania Ave NW, Washington, DC 20500, USA')
@@ -271,7 +274,9 @@ public function testGetProvider()
271274

272275
public function testJapaneseCharacterGeocoding()
273276
{
274-
$cacheKey = sha1(Str::slug(strtolower(urlencode('108-0075 東京都港区港南2丁目16-3'))));
277+
$cacheKey = sha1(app('geocoder')->getProvider()->getName()
278+
. "-" . Str::slug(strtolower(urlencode('108-0075 東京都港区港南2丁目16-3')))
279+
);
275280

276281
app('geocoder')
277282
->geocode('108-0075 東京都港区港南2丁目16-3')

0 commit comments

Comments
 (0)
Please sign in to comment.