Skip to content

Commit

Permalink
cache a few more entities
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshull committed Jan 5, 2024
1 parent 4e72c97 commit 3b32cbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions apps/cms/lib/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,23 @@ defmodule CMS.Repo do
end
end

@decorate cacheable(
cache: @cache,
on_error: :nothing,
opts: [ttl: 60_000]
)
def do_news_entry_by(opts) do
case @cms_api.view("/cms/news", opts) do
{:ok, api_data} -> Enum.map(api_data, &NewsEntry.from_api/1)
_ -> []
end
end

@decorate cacheable(
cache: @cache,
on_error: :nothing,
opts: [ttl: 60_000]
)
def events(opts \\ []) do
case @cms_api.view("/cms/events", opts) do
{:ok, api_data} -> Enum.map(api_data, &Event.from_api/1)
Expand Down
3 changes: 1 addition & 2 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ if config_env() == :prod do
configuration_endpoints: [
conn_opts: [
host: redis_host,
port: 6379,
timeout: 15_000
port: 6379
]
]
],
Expand Down

0 comments on commit 3b32cbc

Please sign in to comment.