Add cached statistics for LocalSites.
Review Request #12303 — Created May 26, 2022 and submitted — Latest diff uploaded
This introduces
LocalSiteManager
, which is the new manager for
LocalSite
objects. It provides methods used to quickly make
determinations about the Local Site usage on the server.The main method currently is
get_stats()
, which returns a dictionary
containing:
- The total number of Local Sites on the server
- The number of public Local Sites
- The number of private Local Sites
- A UUID representing the generated state (which can be used as a
component of other cache keys to enable automatic invalidation)This is cached and invalidated any time a
LocalSite
is created,
deleted, or if thepublic
state has changed, making it fast and
reliable for lookups.There are additional wrappers around this that leverage the cached
state. These include:
has_local_sites()
has_public_local_sites()
has_private_local_sites()
These will soon be used to make some parts of our queries conditional on
their presence, letting us simplify queries in the common case.
Unit tests pass.