diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 049d7a8a16..9880489138 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -116,6 +116,16 @@ config :spandex_ecto, SpandexEcto.EctoLogger, tracer: Explorer.Tracer, otp_app: :explorer +market_history_cache_ttl = + try do + String.to_integer(System.get_env("MARKET_HISTORY_CACHE_TTL")) + rescue + # 6 hours + _ -> 60 * 60 * 6 + end + +config :explorer, Explorer.Market.MarketHistoryCache, ttl: :timer.seconds(market_history_cache_ttl) + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/apps/explorer/lib/explorer/market/market_history_cache.ex b/apps/explorer/lib/explorer/market/market_history_cache.ex index 04b6193716..5cddb7707a 100644 --- a/apps/explorer/lib/explorer/market/market_history_cache.ex +++ b/apps/explorer/lib/explorer/market/market_history_cache.ex @@ -12,7 +12,7 @@ defmodule Explorer.Market.MarketHistoryCache do @last_update_key :last_update @history_key :history # 6 hours - @cache_period 1_000 * 60 * 60 * 6 + @cache_period Application.get_env(:explorer, __MODULE__)[:ttl] @recent_days 30 def fetch do