mobilizon/lib/web/cache/cache.ex
Thomas Citharel de047c8939
Various typespec and compilation improvements
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-09-26 17:52:20 +02:00

35 lines
1.4 KiB
Elixir

defmodule Mobilizon.Web.Cache do
@moduledoc """
Facade module which provides access to all cached data.
"""
alias Mobilizon.Actors.Actor
alias Mobilizon.Web.Cache.ActivityPub
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
@caches [:activity_pub, :feed, :ics]
@type local_actor :: %Actor{domain: nil}
@doc """
Clears all caches for a local actor.
"""
@spec clear_cache(%Actor{domain: nil, preferred_username: String.t()}) :: :ok
def clear_cache(%Actor{preferred_username: preferred_username, domain: nil})
when is_valid_string(preferred_username) do
Enum.each(@caches, &Cachex.del(&1, "actor_" <> preferred_username))
end
defdelegate get_actor_by_name(name), to: ActivityPub
defdelegate get_local_actor_by_name(name), to: ActivityPub
defdelegate get_public_event_by_uuid_with_preload(uuid), to: ActivityPub
defdelegate get_comment_by_uuid_with_preload(uuid), to: ActivityPub
defdelegate get_resource_by_uuid_with_preload(uuid), to: ActivityPub
defdelegate get_todo_list_by_uuid_with_preload(uuid), to: ActivityPub
defdelegate get_todo_by_uuid_with_preload(uuid), to: ActivityPub
defdelegate get_member_by_uuid_with_preload(uuid), to: ActivityPub
defdelegate get_post_by_slug_with_preload(slug), to: ActivityPub
defdelegate get_discussion_by_slug_with_preload(slug), to: ActivityPub
defdelegate get_relay, to: ActivityPub
end