Use cache for user info data.

Later these should be persisted in the user.
This commit is contained in:
Roger Braun 2017-04-30 10:04:54 +02:00
parent 8a0d2b33d8
commit ffc604a2c2
2 changed files with 6 additions and 1 deletions

View File

@ -122,4 +122,9 @@ defmodule Pleroma.User do
key = "nickname:#{nickname}" key = "nickname:#{nickname}"
Cachex.get!(:user_cache, key, fallback: fn(_) -> Repo.get_by(User, nickname: nickname) end) Cachex.get!(:user_cache, key, fallback: fn(_) -> Repo.get_by(User, nickname: nickname) end)
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 end

View File

@ -11,7 +11,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenter do
false false
end end
user_info = User.user_info(user) user_info = User.get_cached_user_info(user)
map = %{ map = %{
"id" => user.id, "id" => user.id,