Interface HomeStatsService

All Known Implementing Classes:
HomeStatsServiceImpl

public interface HomeStatsService
Read + refresh the cached public home-page statistics snapshot.

Reads are anonymous-safe; the snapshot represents only what an anonymous user would see.

No method-level @Secured guards intentionally — the security boundary is the REST surface (POST /stats/home/refresh carries @PreAuthorize("hasAuthority('GROUP_ADMIN')")), and the HomeStatsRefresher background thread invokes refresh() without a SecurityContext (the startup lifecycle event doesn't propagate one, and adding one would require an authenticate-as- agent dance for the dev container). Instead, the impl sets up an anonymous SecurityContext internally for the actual data reads, so the snapshot still represents only what an anonymous user would see. Call-site discipline keeps this safe — only the REST endpoint and the refresher itself call this.

  • Method Summary

    Modifier and Type
    Method
    Description
    Return the most-recent snapshot, loading from disk on first access.
    Recompute the snapshot from scratch (anonymous-user perspective), persist to disk, and update the in-memory cache.
  • Method Details

    • getCached

      @Nullable HomeStats getCached()
      Return the most-recent snapshot, loading from disk on first access. Returns null only if nothing has ever been generated AND the disk cache is missing — the REST layer should handle that as a 503 rather than synchronously building the snapshot under request load.
    • refresh

      HomeStats refresh()
      Recompute the snapshot from scratch (anonymous-user perspective), persist to disk, and update the in-memory cache.