Merge pull request #9687 from colinux/geocoder-cache

Tech: active le cache pour le geocoder pour contourner le rate limiting dans certains contextes
This commit is contained in:
Colin Darie 2023-11-09 16:00:54 +00:00 committed by GitHub
commit 460d565e8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

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

View file

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