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)
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