Output Caching on Methods
The Ometa framework offers the possibility to cache and reuse method data. When enabled, the framework will keep output from a method for a period, if the method is executed again, this data is then reused without executing the method on the external interface. This is most beneficial for data that changes rarely, where slightly outdated data is not an issue.
Caching may be configured on any method, but we recommend only using it for methods that read data. Any flow that executes a method can use caching, for example:
- ADM
- Case Management
- Custom DLL Code
- Test Method in the Business Connector
- As a data extension of another method
- Post Execution
- Audit Trailing
- OData Service Endpoints
- ...
If a method returns an error, the output and this error is not cached.
Configuration
Caching is not enabled by default. To enable it, navigate to the method in the Business Connector, the settings can be found in the middle of the execution tab.
The following options are available:
- Caching: Caching will only take effect when checked.
- Lifetime: Determines how long data from the cache is valid. When expired, the data is no longer reused.
- Input Context: This determines which context fields must be the same for cached data to be reused. A common example for this is data with filters, the input field should then be added. Method input fields are added by default, but other fields can be added as well (e.g. Current SharePoint User).
No additional configuration is needed to support the query options (filtering, sorting and paging in ADM). The caching will only reuse data when the same query options are used.
When caching is enabled for the first time, a pop-up will urge to configure the max cache size setting. It is recommended to configure this to prevent possible issues with disk size, see the section below for more information.
Disk Storage Considerations
Storing method output with many different keys over long periods of time will lead to increased disk space usage. Configuring it with a lot of different unique input contexts or in combination with query options will each be an unique entry in the cache. Output that has expired will be removed automatically.
To prevent excessive disk usage by the caching mechanism of the framework, a new setting was created to limit the maximum allowed size. This setting can be found in the Business Connector > Application menu > Settings > Framework > BCM.
When configured, the framework will monitor the size of the cache directory. If exceeded, cache entries are removed prematurely to reduce the size below the limit. This monitor is timer based (every 5 mins) so provide enough buffer as the limit may be temporarily exceeded.
However, we recommend providing enough space on the disk to prevent this automatic clean up, as it undermines the lifetime and reduces the benefit of the cache. This setting serves only as a last resort to prevent disk issues, consider increasing the setting and the disk when this limit is frequently exceeded.
Cache Renewal
To further optimize responsiveness of dashboards, the framework will automatically refresh cached data that is frequently used. This means that framework will execute the method a minute before its cached data expires and refresh it. As a result, users will not have to wait for the cache to refresh upon expiration.
This only applies to cache entries that are reused more than once with the same context / query options.
The method cache can be manually refreshed by passing the context field Ometa.IsCacheRenewal
with value true
. This will ignore any existing cache, execute the method and update the cache for future usages. This may prove useful for consistent scheduled cache renewals or refreshing data after inserting or updating.
Automatic refreshes made by the system can be recognized by the context field Ometa.AutomaticCachePrefetch
and will only refresh with the exact query options and context. The Ometa.IsCacheRenewal
field will clear all the caches of the method, regardless of query options or context. We recommend using Ometa.IsCacheRenewal
in configuration to trigger a refresh of the cache.
Caching on Methods with Data Extensions
The caching mechanism supports data extensions as follows:
- Each method uses its own caching settings regardless whether it is used as a data extension or not. The cache settings of the main method only apply to itself, not the method output of the data extensions.
- When the main method and all its data extensions use caching, the merged output (including extensions) is cached as a whole. The merged output can then be reused when the input context is the same.
- When the main method or one of its data extensions don't use caching, the merged output is not cached and the output will be merged each execution. As before, methods with caching enabled will still use cached data whenever possible.
The same automatic cache refresh also applies here, when cached data is about to expire and is frequently used, it will be refreshed.
Audit Trailing and Post Execution
Caching has no impact on audit trailing. Whether the output of the method comes from the cache or not, the before and after audit trailing action will fire. Post Execution however is only triggered when the method is executed and not reused from the cache. A warning in the Business Connector will show this while configuring.