From 5a08dee37905c576da3289d7d69e9b114f202634 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 16 Jan 2019 17:44:08 +0300 Subject: [PATCH] cache ap_id in id instead of caching user two times --- lib/pleroma/user.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 5707ba7a2..3becd545c 100644 --- 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 -- 2.45.2