projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
76f8094
)
cache ap_id in id instead of caching user two times
author
rinpatch
<rinpatch@sdf.org>
Wed, 16 Jan 2019 14:44:08 +0000
(17:44 +0300)
committer
rinpatch
<rinpatch@sdf.org>
Wed, 16 Jan 2019 14:44:08 +0000
(17:44 +0300)
lib/pleroma/user.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/user.ex
b/lib/pleroma/user.ex
index 5707ba7a2d0df25de30d5a03e789497fff8d468c..3becd545c34503f3aaca45f9664a4dbf93d264ea 100644
(file)
--- a/
lib/pleroma/user.ex
+++ b/
lib/pleroma/user.ex
@@
-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