Browse Source

cache ap_id in id instead of caching user two times

tags/v0.9.9
rinpatch 5 years ago
parent
commit
5a08dee379
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      lib/pleroma/user.ex

+ 9
- 1
lib/pleroma/user.ex View File

@@ -445,7 +445,15 @@ defmodule Pleroma.User do

def get_cached_by_id(id) do
key = "id:#{id}"
Cachex.fetch!(:user_cache, key, fn _ -> get_by_id(id) end)

ap_id =
Cachex.fetch!(:user_cache, key, fn _ ->
user = get_by_id(id)
Cachex.put(:user_cache, "ap_id:#{user.ap_id}", user)
{:commit, user.ap_id}
end)

get_cached_by_ap_id(ap_id)
end

def get_cached_by_nickname(nickname) do


Loading…
Cancel
Save