View Source Plausible.Site.Cache (Plausible v0.0.1)
The cache allows lookups by both domain
and domain_changed_from
fields - this is to allow traffic from sites whose domains changed within a certain
grace period (see: Plausible.Site.Transfer
).
To differentiate cached Site structs from those retrieved directly from the
database, a virtual schema field from_cache?: true
is set.
This indicates the Plausible.Site
struct is incomplete in comparison to its
database counterpart -- to spare bandwidth and query execution time,
only selected database columns are retrieved and cached.
The @cached_schema_fields
attribute defines the list of DB columns
queried on each cache refresh.
Also see tests for more comprehensive examples.
Summary
Functions
Ensures the cache has non-zero size unless no items exist. Useful for orchestrating app startup to prevent the service going up asynchronously with an empty cache.
Functions
@spec child_spec(Keyword.t()) :: Supervisor.child_spec()
@spec get_site_id(String.t(), Keyword.t()) :: pos_integer() | nil
Ensures the cache has non-zero size unless no items exist. Useful for orchestrating app startup to prevent the service going up asynchronously with an empty cache.
@spec refresh_all(Keyword.t()) :: :ok
@spec refresh_updated_recently(Keyword.t()) :: :ok
@spec touch_site!(Plausible.Site.t(), DateTime.t()) :: Plausible.Site.t()