Skip to content

Commit 96d7821

Browse files
committedMar 25, 2018
Add configurable cache store
1 parent b9dc865 commit 96d7821

File tree

7 files changed

+205
-133
lines changed

7 files changed

+205
-133
lines changed
 

‎CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [4.0.7] - 25 Mar 2018
6+
### Added
7+
- optional dedicated cache store.
8+
- hashed cache keys and hash collision prevention.
9+
- custom cache store configuration instructions.
10+
511
## [4.0.6] - 9 Feb 2018
612
### Added
713
- Laravel 5.6 compatibility.

‎README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,45 @@ Further, a special note on the GoogleMaps provider: if you are using an API key,
5656
See the [Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list
5757
of available adapters and providers.
5858

59+
### Dedicated Cache Store *Recommended*
60+
To implement the dedicated cache store, add another redis store entry in
61+
`config/database.php`, something like the following:
62+
```php
63+
"redis" => [
64+
// ...
65+
66+
"geocode-cache" => [ // choose an appropriate name
67+
'host' => env('REDIS_HOST', '192.168.10.10'),
68+
'password' => env('REDIS_PASSWORD', null),
69+
'port' => env('REDIS_PORT', 6379),
70+
'database' => 1, // be sure this number differs from your other redis databases
71+
],
72+
]
73+
```
74+
75+
You will also need to add an entry in `config/cache.php` to point to this redis
76+
database:
77+
```php
78+
"stores" => [
79+
// ...
80+
81+
"geocode" => [
82+
'driver' => 'redis',
83+
'connection' => 'geocode-cache',
84+
],
85+
],
86+
```
87+
88+
Finally, configure Geocoder for Laraver to use this store. Edit
89+
`config/geocoder.php`:
90+
```php
91+
"cache" => [
92+
"store" => "geocode",
93+
94+
// ...
95+
],
96+
```
97+
5998
### Providers
6099
If you are upgrading and have previously published the geocoder config file, you
61100
need to add the `cache-duration` variable, otherwise cache will be disabled

‎composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"geocoder-php/geoip2-provider": "^4.0",
4242
"geocoder-php/maxmind-binary-provider": "^4.0",
4343
"mockery/mockery": "0.9.*",
44-
"orchestra/database": "3.6.x-dev@dev",
45-
"orchestra/testbench": "^3.6.0",
46-
"orchestra/testbench-browser-kit": "3.6.x-dev@dev",
44+
"orchestra/database": "3.6.*",
45+
"orchestra/testbench": "3.6.*",
46+
"orchestra/testbench-browser-kit": "3.6.*",
4747
"orchestra/testbench-dusk": "3.6.x-dev@dev",
4848
"php-coveralls/php-coveralls": "*",
4949
"phpunit/phpunit": "^7.0",

‎config/geocoder.php

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,15 @@
66
use Http\Client\Curl\Client;
77

88
return [
9-
10-
/*
11-
|--------------------------------------------------------------------------
12-
| Cache Settings
13-
|--------------------------------------------------------------------------
14-
|
15-
| Here you may define all of the cache settings.
16-
|
17-
*/
18-
199
'cache' => [
2010

2111
/*
22-
|--------------------------------------------------------------------------
12+
|-----------------------------------------------------------------------
2313
| Cache Store
24-
|--------------------------------------------------------------------------
14+
|-----------------------------------------------------------------------
2515
|
26-
| Specify the cache store to use for caching. The default value null will
27-
| use the default cache store specified in the cache.php cofig file.
16+
| Specify the cache store to use for caching. The value "null" will use
17+
| the default cache store specified in /config/cache.php file.
2818
|
2919
| Default: null
3020
|
@@ -33,13 +23,13 @@
3323
'store' => null,
3424

3525
/*
36-
|--------------------------------------------------------------------------
26+
|-----------------------------------------------------------------------
3727
| Cache Duration
38-
|--------------------------------------------------------------------------
28+
|-----------------------------------------------------------------------
3929
|
40-
| Specify the cache duration in minutes. The default approximates a forever
41-
| cache, but there are certain issues with Laravel's forever caching
42-
| methods that prevent us from using them in this project.
30+
| Specify the cache duration in minutes. The default approximates a
31+
| "forever" cache, but there are certain issues with Laravel's forever
32+
| caching methods that prevent us from using them in this project.
4333
|
4434
| Default: 9999999 (integer)
4535
|
@@ -49,9 +39,9 @@
4939
],
5040

5141
/*
52-
|--------------------------------------------------------------------------
42+
|---------------------------------------------------------------------------
5343
| Providers
54-
|--------------------------------------------------------------------------
44+
|---------------------------------------------------------------------------
5545
|
5646
| Here you may specify any number of providers that should be used to
5747
| perform geocaching operations. The `chain` provider is special,
@@ -76,9 +66,9 @@
7666
],
7767

7868
/*
79-
|--------------------------------------------------------------------------
69+
|---------------------------------------------------------------------------
8070
| Adapter
81-
|--------------------------------------------------------------------------
71+
|---------------------------------------------------------------------------
8272
|
8373
| You can specify which PSR-7-compliant HTTP adapter you would like to use.
8474
| There are multiple options at your disposal: CURL, Guzzle, and others.
@@ -92,9 +82,9 @@
9282
'adapter' => Client::class,
9383

9484
/*
95-
|--------------------------------------------------------------------------
85+
|---------------------------------------------------------------------------
9686
| Reader
97-
|--------------------------------------------------------------------------
87+
|---------------------------------------------------------------------------
9888
|
9989
| You can specify a reader for specific providers, like GeoIp2, which
10090
| connect to a local file-database. The reader should be set to an

0 commit comments

Comments
 (0)