Tests: Use NullCache for async tests.
[akkoma] / test / support / null_cache.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.NullCache do
6 @moduledoc """
7 A module simulating a permanently empty cache.
8 """
9 @behaviour Pleroma.Caching
10
11 @impl true
12 def get!(_, _), do: nil
13
14 @impl true
15 def put(_, _, _, _ \\ nil), do: {:ok, true}
16
17 @impl true
18 def stream!(_, _), do: []
19
20 @impl true
21 def get(_, _), do: {:ok, nil}
22
23 @impl true
24 def fetch!(_, _, func) do
25 {_, res} = func.()
26 res
27 end
28
29 @impl true
30 def get_and_update(_, _, func) do
31 func.(nil)
32 end
33
34 @impl true
35 def expire_at(_, _, _), do: {:ok, true}
36
37 @impl true
38 def exists?(_, _), do: {:ok, false}
39
40 @impl true
41 def execute!(_, func) do
42 func.(:nothing)
43 end
44
45 @impl true
46 def del(_, _), do: {:ok, true}
47 end