Merge remote-tracking branch 'pleroma/develop' into dont-crash-email-settings
[akkoma] / test / support / null_cache.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 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!(_, key, func) do
25 case func.(key) do
26 {_, res} -> res
27 res -> res
28 end
29 end
30
31 @impl true
32 def get_and_update(_, _, func) do
33 func.(nil)
34 end
35
36 @impl true
37 def expire_at(_, _, _), do: {:ok, true}
38
39 @impl true
40 def exists?(_, _), do: {:ok, false}
41
42 @impl true
43 def execute!(_, func) do
44 func.(:nothing)
45 end
46
47 @impl true
48 def del(_, _), do: {:ok, true}
49 end