Lotus cache facade. If no adapter configured, acts as a no-op pass-through.
Summary
Functions
Builds the per-entry options for a cache write.
Removes one entry.
Invalidates all cache entries associated with the given scope.
Invalidates every entry that carries one of tags.
How far one delete/1 or invalidate_tags/1 on the configured adapter
reaches.
Types
@type key() :: binary()
@type opts() :: Keyword.t()
@type ttl_ms() :: non_neg_integer()
@type value() :: any()
Functions
Builds the per-entry options for a cache write.
Layers the caller's :cache option over the entry options set in
application config, then adds the invalidation tags. A caller that passes
no :cache option, or an atom such as :bypass, still gets the
configured defaults.
Removes one entry.
When the adapter's delete is node-local the call is relayed to the other
nodes of the cluster. See scope/1.
@spec enabled?() :: boolean()
Invalidates all cache entries associated with the given scope.
Uses tag-based invalidation — each scoped cache entry is tagged with
"scope:<digest>", so this clears only entries for the specified scope
without flushing the entire source cache.
Examples
Lotus.Cache.invalidate_scope(%{tenant_id: 42})
Lotus.Cache.invalidate_scope(%{role: :admin})
Invalidates every entry that carries one of tags.
When the adapter's tag bookkeeping is node-local the call is relayed to
the other nodes of the cluster. See scope/1.
@spec scope(Lotus.Cache.Adapter.relayed_operation()) :: :node | :cluster
How far one delete/1 or invalidate_tags/1 on the configured adapter
reaches.
:node means the call only touches the calling node, so it is relayed
to the other nodes over Lotus.Notifier and applied there by
Lotus.Cache.Relay. :cluster means one call already reaches every
node and nothing is relayed. An adapter that does not implement
Lotus.Cache.Adapter.scope/1 counts as :node for both. Without a
configured adapter the answer is :cluster, because there is nothing
to relay.