2020-12-18 10:49:01 -08:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 12:38:50 -08:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-12-18 10:49:01 -08:00
|
|
|
# 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
|
2020-12-21 02:42:53 -08:00
|
|
|
def fetch!(_, key, func) do
|
|
|
|
case func.(key) do
|
|
|
|
{_, res} -> res
|
|
|
|
res -> res
|
|
|
|
end
|
2020-12-18 10:49:01 -08:00
|
|
|
end
|
|
|
|
|
2024-02-06 11:34:59 -08:00
|
|
|
@impl true
|
|
|
|
def fetch(_, key, func), do: func.(key)
|
|
|
|
|
2020-12-18 10:49:01 -08:00
|
|
|
@impl true
|
|
|
|
def get_and_update(_, _, func) do
|
|
|
|
func.(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def expire_at(_, _, _), do: {:ok, true}
|
|
|
|
|
2024-02-06 11:34:59 -08:00
|
|
|
@impl true
|
|
|
|
def expire(_, _, _), do: {:ok, true}
|
|
|
|
|
2020-12-18 10:49:01 -08:00
|
|
|
@impl true
|
|
|
|
def exists?(_, _), do: {:ok, false}
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def execute!(_, func) do
|
|
|
|
func.(:nothing)
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def del(_, _), do: {:ok, true}
|
|
|
|
end
|