logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

null_cache.ex (1005B)


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