#1026: VisitorbookCache.kt

projectforge-business/src/main/kotlin/org/projectforge/business/orga/VisitorbookCache.kt Cache Component, projectforge-business/src/main/kotlin/org/projectforge/business/orga/VisitorbookCache.kt 115 lines · 71 code · 34 comments · 10 blank
In-memory cache for visitorbook aggregate data (last visit date, number of visits). Extends AbstractCache for automatic refresh lifecycle. Provides VisitorbookInfo summaries without querying the database per visitorbook display.

Architecture

Refresh Strategy

On refresh(), the cache runs in a read-only transaction and:

  1. Loads all non-deleted visitorbooks into a map (keyed by ID) with empty VisitorbookInfo.
  2. Loads all non-deleted visitorbook entries, grouped by visitorbook ID.
  3. For each group, fills the info: lastDateOfVisit (first/latest entry by date desc), latestArrived/latestDeparted, and numberOfVisits (count).

Selective Invalidation

setExpired(id) updates a single visitorbook's info without full cache refresh, using the queryVisitEntries named query filtered by visitorbook ID. This is called after any insert/update/delete of a visitorbook entry via VisitorbookService.

Thread Safety

Access to visitorbookMap is synchronized. The refresh() method works with a new map and atomically replaces the reference, avoiding stale reads.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
2c9ea00ac VisitorbookCache fixed.
ba2479571 Migration stuff in progress...
b3293f0cc PersistenceService/Context: stats handling improved.
b5dc26e24 Migration stuff in progress...