Cache adapter for ExNominatim backed by Cachex v4.x.
Usage
Add cachex to your dependencies:
{:cachex, "~> 4.1"}Start a Cachex instance in your supervision tree:
children = [
{Cachex, name: :ex_nominatim, limit: 10_000},
...
]Then pass the adapter to your endpoint calls:
ExNominatim.search([q: "Athens", cache: ExNominatim.CachexCache])Configuration
config :ex_nominatim, :cache_name, :ex_nominatim # Cachex cache name (default: :ex_nominatim)
config :ex_nominatim, :cache_ttl, 86_400_000 # TTL in ms (default: 24 hours)Behaviour
- Only successful results are cached. Errors never cache.
- If Cachex is not started or not in the dependency list, the
:cacheoption is silently ignored. - Cache keys are based on endpoint and normalized query parameters.
- This module is only compiled when Cachex is available at runtime.