diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-01-06 15:22:35 -0600 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-01-06 15:22:35 -0600 |
commit | 1438fd958325c3d469315c478f06def9e4dd0de3 (patch) | |
tree | 738e7e9ce8e0e0af89d9dff411191643cbf45aab /test/support/null_cache.ex | |
parent | 2aeb229de3f59e1704c633c31415e7e834f6ba67 (diff) | |
parent | 5e128a6be30563adc3b8a938aa68d18ac04cdfa0 (diff) | |
download | pleroma-1438fd958325c3d469315c478f06def9e4dd0de3.tar.gz pleroma-1438fd958325c3d469315c478f06def9e4dd0de3.zip |
Merge remote-tracking branch 'upstream/develop' into block-behavior
Diffstat (limited to 'test/support/null_cache.ex')
-rw-r--r-- | test/support/null_cache.ex | 49 |
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 |