aboutsummaryrefslogtreecommitdiff
path: root/test/support/null_cache.ex
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2020-12-30 17:10:02 -0600
committerAlex Gleason <alex@alexgleason.me>2020-12-30 17:10:02 -0600
commitcbce88007672dc810cb345bb9872a009cbdc93d8 (patch)
tree45be2517812f2a598d9b6133554038a87d4b9f46 /test/support/null_cache.ex
parent83770b7b391fdf8bdc22f63047b1cf444a7b16ce (diff)
parent38924166eb3228deb71a2e23f1e8fd3255c6bd85 (diff)
downloadpleroma-cbce88007672dc810cb345bb9872a009cbdc93d8.tar.gz
Merge remote-tracking branch 'upstream/develop' into aliases
Diffstat (limited to 'test/support/null_cache.ex')
-rw-r--r--test/support/null_cache.ex49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/support/null_cache.ex b/test/support/null_cache.ex
new file mode 100644
index 000000000..c63df6a39
--- /dev/null
+++ b/test/support/null_cache.ex
@@ -0,0 +1,49 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.NullCache do
+ @moduledoc """
+ A module simulating a permanently empty cache.
+ """
+ @behaviour Pleroma.Caching
+
+ @impl true
+ def get!(_, _), do: nil
+
+ @impl true
+ def put(_, _, _, _ \\ nil), do: {:ok, true}
+
+ @impl true
+ def stream!(_, _), do: []
+
+ @impl true
+ def get(_, _), do: {:ok, nil}
+
+ @impl true
+ def fetch!(_, key, func) do
+ case func.(key) do
+ {_, res} -> res
+ res -> res
+ end
+ end
+
+ @impl true
+ def get_and_update(_, _, func) do
+ func.(nil)
+ end
+
+ @impl true
+ def expire_at(_, _, _), do: {:ok, true}
+
+ @impl true
+ def exists?(_, _), do: {:ok, false}
+
+ @impl true
+ def execute!(_, func) do
+ func.(:nothing)
+ end
+
+ @impl true
+ def del(_, _), do: {:ok, true}
+end