I. Overview
1. Application scenario
When accessing the report, if the data calculation amount of the template is large, the data will be re-read from the server for calculation each time the access is made, which increases the pressure on the server and slows down the access to the report. This can be set the template calculation result is cached to solve this problem.
2. Function introduction
After setting the cache of template calculation result, when the visited template is accessed again, the calculation result is directly read from the cache to reduce the pressure on the server and improve the access speed of the report.
3. Principle
The principle description is as follows:
Client A accesses the template on the server, reads it from the database, generates the desired template result file, caches it in the memory, and sends it back to Client A.
When client B accesses this template on the server, if the returned result is the same as the result returned by client A, it will not read from the database, but directly read the template data cached by A, and then send it back to client B.
Note 1: Currently only cpt template calculation result caching is supported.
Note 2: Read the template calculation result cache must meet: the same template and have the same parameters.
II. Steps
Cache the template calculation result has two opening methods, and the cache data validity period of the two opening methods is different.
1. Open by using __cache__ parameter
Add &__cache__=true to the path to the report, which means that the report is enabled for calculation result caching, as shown below:
http://localhost:8075/webroot/decision/view/report?viewlet=GettingStartedEN.cpt&__cache__=true
Note 1: As long as the system does not have GC (Garbage Collections), the cache will always remain.
Note 2: When reading data from the cache, add &__cache__=true after the URL.
2. Set report cache effective time
In the designer, click "Template>Web Attributes>Basic" and fill in the "Report Cache Effective Time" to open it. The setting page is as shown in the figure below:
Note: The value of "Report Cache Effective Time" is an integer greater than 0. After the effective time is reached, the cached data will be cleared.