Use cache for user info data.
Later these should be persisted in the user.
This commit is contained in:
parent
8a0d2b33d8
commit
ffc604a2c2
@ -122,4 +122,9 @@ def get_cached_by_nickname(nickname) do
|
||||
key = "nickname:#{nickname}"
|
||||
Cachex.get!(:user_cache, key, fallback: fn(_) -> Repo.get_by(User, nickname: nickname) end)
|
||||
end
|
||||
|
||||
def get_cached_user_info(user) do
|
||||
key = "user_info:#{user.id}"
|
||||
Cachex.get!(:user_cache, key, fallback: fn(_) -> user_info(user) end)
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ def to_map(user, opts) do
|
||||
false
|
||||
end
|
||||
|
||||
user_info = User.user_info(user)
|
||||
user_info = User.get_cached_user_info(user)
|
||||
|
||||
map = %{
|
||||
"id" => user.id,
|
||||
|
Loading…
Reference in New Issue
Block a user