Get users fresh, might so we don't make new keys all the time.

This commit is contained in:
Roger Braun 2017-04-30 15:05:16 +02:00
parent bb1d08a47c
commit a173fb9e41
2 changed files with 5 additions and 1 deletions

View file

@ -123,6 +123,10 @@ defmodule Pleroma.User do
Cachex.get!(:user_cache, key, fallback: fn(_) -> Repo.get_by(User, nickname: nickname) end)
end
def get_cached_by_nickname(nickname) do
Repo.get_by(User, nickname: nickname)
end
def get_cached_user_info(user) do
key = "user_info:#{user.id}"
Cachex.get!(:user_cache, key, fallback: fn(_) -> user_info(user) end)

View file

@ -20,7 +20,7 @@ defmodule Pleroma.Web.WebFinger do
regex = ~r/(acct:)?(?<username>\w+)@#{host}/
case Regex.named_captures(regex, resource) do
%{"username" => username} ->
user = User.get_cached_by_nickname(username)
user = User.get_by_nickname(username)
{:ok, represent_user(user)}
_ -> nil
end