Last updated
Last updated
Before starting with cache refresher notifications it's a good idea to ensure you need to use them. If you want to react to changes in content, for instance, there's no real reason to use these notifications. This is due to the being easier to work with. If you need to react to changes in the cache, then these are the notifications for you.
Cache refresher notifications are sent when the cache has refreshed. There are multiple different types of cache refresher notifications. These types are based on what type has been updated in the cache, for instance, content or media. All these notifications inherit from the same base notification: CacheRefresherNotification
.
The base notification is implemented in the following way:
As you can see this notification contains two properties, a MessageObject
and a MessageType
. The MessageType
specifies what kind of cache operation was performed, for example RemoveById
. The possible message types is as follows:
The other parameter MessageObject
will depend on what type of cache refresher notification you're handling. If you for instance handle the ContentCacheNotification
, the message object will be ContentCacheRefresher.JsonPayload[]
.
This object contains the Id and key of the item being updated, as well as an enum specifying how the tree is updated:
An example of working with the ContentCacheNotification
can be seen here:
Example of how to use a CacheRefresher Notification