Money.ExchangeRates.Cache behaviour (Money v6.1.0)

Copy Markdown View Source

Defines the cache behaviour for exchange rates.

Summary

Callbacks

Retrieve the exchange rates for a given date.

Initialize the cache when the exchange rates retriever is started

Return the timestamp when the exchange rates were last updated.

Retrieve the latest exchange rates from the cache.

Store the historic exchange rates for a given date in the cache.

Store the latest exchange rates in the cache.

Terminate the cache when the retriever process stops normally

Callbacks

historic_rates(t)

@callback historic_rates(Date.t()) :: {:ok, map()} | {:error, {Exception.t(), String.t()}}

Retrieve the exchange rates for a given date.

init()

@callback init() :: any()

Initialize the cache when the exchange rates retriever is started

last_updated()

@callback last_updated() :: {:ok, DateTime.t()} | {:error, {Exception.t(), String.t()}}

Return the timestamp when the exchange rates were last updated.

latest_rates()

@callback latest_rates() :: {:ok, map()} | {:error, {Exception.t(), String.t()}}

Retrieve the latest exchange rates from the cache.

store_historic_rates(map, t)

@callback store_historic_rates(map(), Date.t()) :: :ok

Store the historic exchange rates for a given date in the cache.

store_latest_rates(map, t)

@callback store_latest_rates(map(), DateTime.t()) :: :ok

Store the latest exchange rates in the cache.

terminate()

@callback terminate() :: any()

Terminate the cache when the retriever process stops normally