Commit ffc604a2 authored by lain's avatar lain

Use cache for user info data.

Later these should be persisted in the user.
parent 8a0d2b33
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment