Message Caching
The Cache(s) store the latest message for a topic so late-joining subscribers can receive current state of the world. Cache behaviour for a message is controlled by the cacheMode header field described in Message Structure.
Cache Modes
| Cache Mode | Behaviour |
|---|---|
CACHE | The message is cached and automatically removed when the publishing application goes offline. This is the default setting. |
CACHE_FOREVER | The message is cached and remains available beyond the lifetime of the publishing application. Use this for data that should survive publisher shutdowns / restarts |
DO_NOT_CACHE | The message is published to subscribers but is not stored in the cache(s). Use this for transient events that should only be delivered live |
Removal of Cached Data
Voiding Messages
A publisher can remove cached data by publishing a message on the same topic with the voided header field set to true (see Message Structure). A voided message indicates that the data is no longer valid and should no longer be used or cached.
Voided messages are routed separately from valid messages so applications can decide how to handle removals without accidentally processing them as active data.
Automatic Eviction
Messages published with CacheMode.CACHE are automatically removed from the cache when the publishing application goes offline. Messages published with CacheMode.CACHE_FOREVER are not automatically removed when the publisher goes offline.
An application is considered offline when:
- the application performs a graceful disconnection from the platform.
- the application stops heartbeating and is deemed to have timed out.