Caching
The main objective of the cache mediator is to prevent the server from wasting time, and from overload by processing a request that has already been received and processed in advance.
Let's look at the syntax:
<cache [id="string"] [hashGenerator="class"] [timeout="seconds"] [scope=(per-host | per-mediator)] collector=(true | false) [maxMessageSize="in-bytes"]> <onCacheHit [sequence="key"]> (mediator)+ </onCacheHit>? <implementation type=(memory | disk) maxSize="int"/> </cache>
When the service receives the same request processed earlier, it executes the onCacheHit
sequence, which can be defined online or referred to from an existing sequence.
To use the cache mediator, we need to configure two places for the services:
- In sequence: To check the requests:
collector="false"
- Out sequence: To store the result of the service:
collector="true"
In the next example, we will use a cache mediator inside the API to store the result and...