diff --git a/lib/cms/repo.ex b/lib/cms/repo.ex index 59ac5e8bba..c05d91793d 100644 --- a/lib/cms/repo.ex +++ b/lib/cms/repo.ex @@ -110,12 +110,6 @@ defmodule CMS.Repo do end end - @decorate cacheable( - cache: @cache, - key: "cms.repo|whats-happening", - on_error: :nothing, - opts: [ttl: @ttl] - ) def do_whats_happening do @cms_api.view("/cms/whats-happening", []) end diff --git a/lib/dotcom_web/controllers/page_controller.ex b/lib/dotcom_web/controllers/page_controller.ex index 11e21f1978..9442e4a5fe 100644 --- a/lib/dotcom_web/controllers/page_controller.ex +++ b/lib/dotcom_web/controllers/page_controller.ex @@ -3,6 +3,7 @@ defmodule DotcomWeb.PageController do use Dotcom.Gettext.Sigils use DotcomWeb, :controller + use Nebulex.Caching.Decorators import DotcomWeb.CMSHelpers, only: [cms_route_to_class: 1] import CMS.Repo, only: [photo: 0] @@ -23,6 +24,9 @@ defmodule DotcomWeb.PageController do @subway_status_cache Application.compile_env!(:dotcom, :system_status_cache_modules)[:subway] + @cache Application.compile_env!(:dotcom, :cache) + @ttl :timer.hours(4) + def index(conn, _params) do {promoted, remainder} = whats_happening_items() banner = banner() @@ -77,6 +81,12 @@ defmodule DotcomWeb.PageController do |> Enum.map(&add_utm_url/1) end + @decorate cacheable( + cache: @cache, + key: "PageController.whats_happening_items", + on_error: :nothing, + opts: [ttl: @ttl] + ) @spec whats_happening_items :: whats_happening_set defp whats_happening_items do Repo.whats_happening()