From 04f429abef02049e196f751aaa1ec0f3abbd4d99 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 9 Nov 2023 16:36:23 +0100 Subject: [PATCH 1/2] chore(bundle): update geocoder 1.6 => 1.8 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28f64329f..d093920b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -272,7 +272,7 @@ GEM et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) geo_coord (0.2.0) - geocoder (1.6.5) + geocoder (1.8.2) globalid (1.2.1) activesupport (>= 6.1) gon (6.4.0) From 01aaec6e907215eca10e82fa147ff984bc994fab Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 9 Nov 2023 16:36:51 +0100 Subject: [PATCH 2/2] chore(geocoder): enable caching for geocoder --- config/initializers/geocoder.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index 169dcfb24..b835714ca 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1 +1,7 @@ -Geocoder.configure(lookup: :ban_data_gouv_fr, use_https: true) +cache_configuration = if ENV['REDIS_CACHE_URL'].present? + { cache: Redis.new(url: ENV['REDIS_CACHE_URL']), cache_options: { prefix: "geocoder:", expiration: 6.hours } } +else + { cache: Geocoder::CacheStore::Generic.new(Rails.cache, { prefix: "geocoder:" }) } # generic has no specific expiration support as of geocoder 1.8 +end + +Geocoder.configure(lookup: :ban_data_gouv_fr, use_https: true, **cache_configuration)