fix(user): correct cache key invalidation
This commit is contained in:
parent
0a076443ad
commit
c3fe61c2f5
3 changed files with 38 additions and 19 deletions
|
|
@ -1988,14 +1988,26 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
describe "caching" do
|
||||
test "set_cache stores friends under the AP ID cache key" do
|
||||
user = insert(:user)
|
||||
|
||||
User.set_cache(user)
|
||||
|
||||
assert {:ok, []} = Cachex.get(:user_cache, "friends_ap_ids:#{user.ap_id}")
|
||||
assert {:ok, nil} = Cachex.get(:user_cache, "friends_ap_ids:#{user.nickname}")
|
||||
end
|
||||
|
||||
test "invalidate_cache works" do
|
||||
user = insert(:user)
|
||||
|
||||
User.set_cache(user)
|
||||
User.get_cached_by_id(user.id)
|
||||
User.invalidate_cache(user)
|
||||
|
||||
{:ok, nil} = Cachex.get(:user_cache, "ap_id:#{user.ap_id}")
|
||||
{:ok, nil} = Cachex.get(:user_cache, "nickname:#{user.nickname}")
|
||||
{:ok, nil} = Cachex.get(:user_cache, "friends_ap_ids:#{user.ap_id}")
|
||||
{:ok, nil} = Cachex.get(:user_cache, "id:#{user.id}")
|
||||
end
|
||||
|
||||
test "User.delete() plugs any possible zombie objects" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue