File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff 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
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