AuroraMeter. Subscriptions
(Aurora Meter v0.4.0)
View Source
Cached subscription lookups.
Resolving a tenant's plan on every check/2 or reserve/3 would otherwise
cost one database query per request. get/1 memoises the storage lookup in
ETS for :subscription_cache_ttl milliseconds (default 5s, 0 disables), and
every write through AuroraMeter.Storage.put_subscription/1 evicts the entry
locally and broadcasts the eviction over PubSub so other nodes drop it too.
The cache is transparent: it only ever holds what storage returned.
Summary
Functions
Returns the tenant's subscription (or nil), served from the cache when warm.
Drops the cached subscription for tenant on this node and announces the
change so every other node drops it as well.
Functions
@spec get(term()) :: AuroraMeter.Schema.Subscription.t() | nil
Returns the tenant's subscription (or nil), served from the cache when warm.
Examples
iex> AuroraMeter.Subscriptions.get("nobody_7940")
nil
@spec invalidate(term()) :: :ok
Drops the cached subscription for tenant on this node and announces the
change so every other node drops it as well.
Examples
iex> AuroraMeter.Subscriptions.invalidate("org_1")
:ok