Skip to content

Commit 3aa3813

Browse files
fix: CI
1 parent 9e230f8 commit 3aa3813

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/cesium_link/links.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,27 @@ defmodule CesiumLink.Links do
6464
6565
"""
6666
def list_unarchived_links_by_index do
67-
case CesiumLink.Standalone.get("links") do
68-
nil ->
67+
case safe_get_from_redis("links") do
68+
{:ok, nil} ->
6969
links = list_unarchived_links_by_index_from_db()
7070
CesiumLink.Standalone.put("links", links)
7171
links
7272

73-
links ->
73+
{:ok, links} ->
7474
links
75+
76+
{:error, _reason} ->
77+
list_unarchived_links_by_index_from_db()
7578
end
7679
end
7780

81+
defp safe_get_from_redis(key) do
82+
{:ok, CesiumLink.Standalone.get(key)}
83+
rescue
84+
exception ->
85+
{:error, exception}
86+
end
87+
7888
def list_unarchived_links_by_index_from_db do
7989
Repo.all(from l in Link, where: l.archived == false, order_by: [asc: l.index])
8090
end

lib/cesium_link/redis_cache.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule CesiumLink.Standalone do
2+
@moduledoc """
3+
Standalone redis cache.
4+
"""
25
use Nebulex.Cache,
36
otp_app: :safira,
47
adapter: NebulexRedisAdapter

0 commit comments

Comments
 (0)