File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,14 +64,26 @@ 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 ( )
78+ end
79+ end
80+
81+ defp safe_get_from_redis ( key ) do
82+ try do
83+ { :ok , CesiumLink.Standalone . get ( key ) }
84+ rescue
85+ exception ->
86+ { :error , exception }
7587 end
7688 end
7789
Original file line number Diff line number Diff line change 11defmodule CesiumLink.Standalone do
2+ @ moduledoc """
3+ Standalone redis cache.
4+ """
25 use Nebulex.Cache ,
36 otp_app: :safira ,
47 adapter: NebulexRedisAdapter
You can’t perform that action at this time.
0 commit comments