Sfoglia il codice sorgente

Use cache for user info data.

Later these should be persisted in the user.
tags/v0.9.9
Roger Braun 7 anni fa
parent
commit
ffc604a2c2
2 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. +5
    -0
      lib/pleroma/user.ex
  2. +1
    -1
      lib/pleroma/web/twitter_api/representers/user_representer.ex

+ 5
- 0
lib/pleroma/user.ex Vedi File

@@ -122,4 +122,9 @@ defmodule Pleroma.User 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

+ 1
- 1
lib/pleroma/web/twitter_api/representers/user_representer.ex Vedi File

@@ -11,7 +11,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenter do
false
end

user_info = User.user_info(user)
user_info = User.get_cached_user_info(user)

map = %{
"id" => user.id,


Loading…
Annulla
Salva