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) 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)