Cache Hierarchy
1
L1: Caffeine in-memory cache (new in v1.6.5)
Local to the Nexus Core process. Backed by Caffeine with a maximum capacity of 100,000 entries and W-TinyLFU eviction, which provides near-optimal hit rates under skewed access patterns. Each entry has a per-entry TTL driven by the addon’s
getCacheTTL() value. Entries expire automatically without a background sweep thread.Any addon can opt out of L1 by overriding l1CacheEnabled() to return false. Reads for that addon will always pass through to L2.2
L2: Redis cache
Shared across every server in the network. Holds serialized documents with per-addon TTL. All Spigot servers indirectly see the same state because all writes flow through Nexus Core and land here first.
3
L3: MongoDB persistence
The durable backing store. Queried only when data is absent from both cache layers, and updated on every write-through operation.
Cache Behavior by Request Type
Dynamic TTL
Every DataAddon defines its own cache lifetime by overridinggetCacheTTL(). The returned value (in seconds) controls how long documents stay in both the Caffeine L1 cache and Redis L2 before automatic expiration.
Opting Out of L1 Per Addon
Overridel1CacheEnabled() on any DataAddon to bypass the Caffeine L1 layer for that addon entirely:
L1 Invalidation Bus (Cluster Mode)
In v1.6.5,L1InvalidationBus replaces the 10-second L1 sync poll for immediate invalidation: the moment a SET_DATA or REMOVE_DATA completes, a message is broadcast on a dedicated Redis Pub/Sub channel so all Nexus Core instances drop their L1 entry at once.
The bus is disabled by default (zero overhead for single-instance deployments). Enable it when running Nexus Core horizontally:
L2 Auto-sync (Keyspace Notifications)
In addition to the invalidation bus, Nexus Core keeps L1 and L2 synchronized using Redis Keyspace Notifications:Sliding TTL
Nexus Core uses a touch-to-renew model: every time a document is read from Redis, its TTL is refreshed. Frequently accessed data stays in cache indefinitely, while cold data expires naturally and frees memory.Cache Metrics
As of v1.6.5,CacheMetrics tracks per-addon L1, L2, and L3 (MongoDB) hit counts and L1 hit ratio. These are exposed through the web dashboard and the /api/cache-metrics endpoint.
The Cache Performance table in the dashboard shows a per-addon breakdown with a visual ratio bar, and the Key Browser panel lets you page through cached keys per addon and inspect their live values and source layer (L1 or L2).
Related Topics
- Request Types — which request types trigger which cache behavior
- DataAddon API —
getCacheTTL(),l1CacheEnabled(), and the full addon method reference - Redis Key Strategy — how cache keys are constructed