# `Forex.Cache`
[🔗](https://github.com/greven/forex/blob/1.1.2/lib/forex/cache.ex#L1)

Since the ECB reference rates are usually updated at around 16:00 CET
every working day we should cache the response.

This module defines a simple caching layer behaviour to cache the
responses from the `Forex.Feed` module.

The default implementation uses ETS as the cache storage.
You can override the cache module by setting the `:cache_module` configuration option:

```elixir
config :forex, cache_module: MyApp.ForexCache
```

# `delete`

```elixir
@callback delete(key :: any()) :: term()
```

Delete an entry from the cache with the given `key`.

# `get`

```elixir
@callback get(key :: any(), opts :: Keyword.t()) :: term()
```

Get the cache entry with the given `key`.
Returns `nil` if the entry does not exist.

# `init`

```elixir
@callback init() :: any()
```

Inits the cache.

# `initialized?`

```elixir
@callback initialized?() :: boolean()
```

Check if the cache is initialized.

# `last_updated`

```elixir
@callback last_updated() :: [{any(), DateTime.t()}] | nil
```

Get a list of all keys in the cache and the respective
updated at timestamps.

# `last_updated`

```elixir
@callback last_updated(key :: any()) :: DateTime.t() | nil
```

Get the latest updated at timestamp for the given `key`.
Returns `nil` if the entry does not exist.

# `put`

```elixir
@callback put(key :: any(), value :: term(), DateTime.t()) :: term()
```

Put a new entry into the cache with the given `key` and `value`.

# `reset`

```elixir
@callback reset() :: any()
```

Reset the cache table.

# `resolve`

```elixir
@callback resolve(key :: any(), resolver :: mfa() | function(), opts :: Keyword.t()) ::
  term()
```

Resolve the cache entry with the given `key` using the given `resolver`.
If the entry does not exist, the `resolver` function, an mfa tuple, is called and the
result is stored in the cache.

Example:

  Forex.Cache.resolve(:latest_rates, {Forex.Feed, :fetch_latest_rates, []})

# `terminate`

```elixir
@callback terminate() :: any()
```

Terminate the cache process.

# `cache_mod`

# `delete`

# `historic_rates`

# `init`

# `initialized?`

# `last_ninety_days_rates`

# `last_updated`

# `last_updated`

# `latest_rates`

# `reset`

# `resolve`

# `terminate`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
