Form Caches: Difference between revisions

From IHRIS Wiki
No edit summary
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The iHRIS software caches data saved in the database (or XML file or LDAP server) for faster access and the ability to create indices.  These caches are used, for example, to populate reports and drop-down lists.
The data for a form ''XXXXX'' may be cached into a table ''hippo_XXXXX.''  This hippo table can be used for:
The data for a form ''XXXXX'' may be cached into a table ''hippo_XXXXX.''  This hippo table can be used for:
*To generate reports to [[Custom Reporting -- An Overview | Custom Reporting]]
*To generate reports to [[Custom Reporting -- An Overview | Custom Reporting]]
*To export data for [[Managing Decentralized iHRIS Manage with Launchpad|decentralized data management]]
*To export data for [[Managing Decentralized iHRIS Manage with Launchpad|decentralized data management]]
==Hippo Table Structure==
==Hippo Table Structure==
If a form XXXXX has a field YYYYY then the hippo_XXXXX table will have a column `XXXXX+YYYYY.`  There is also a column `XXXXX+id` containing the id of the form and a column `XXXXX+parent` containing the parent form, if any.
If a form XXXXX has a field YYYYY then the hippo_XXXXX table will have a column `XXXXX+YYYYY.`  There is also a column `XXXXX+id` containing the id of the form and a column `XXXXX+parent` containing the parent form, if any.
==Cache Times==
==Cache Times and Command Line==
The hippo tables are generated by a background process once a form cache is consider stale.  The background process is spawned by default every 10 minutes.  This can be specified by setting the value in magic data at:
 
*/modules/CachedForms/times/background
The hippo tables are generated by a background process once a form cache is consider stale.  See the [[Configuring Form Cache Generation Timing]] document for information on timing for form caches and information on manually creating the form caches from the command line.
The stale time for a report defaults to 10 minutes. This can be over-ridden by the following setting values in magic data:
 
*/modules/CachedForms/times/stale
To see this tutorial for different versions of the software see the following:{{otherversions|Exporting and Updating Form Caches Using Profiles}}
*/modules/CachedForms/times/stale_time_by_storage/ZZZZZ
 
*/modules/CachedForms/times/stale_time_by_form/XXXXX 
=Editing, Exporting and Updating Form Caches Using Profiles=
where ZZZZZ is the [[Form Storage Mechanisms|storage mechanism]] that form XXXXX uses.
 
In version '''4.0.6''' we add the ability to create ''profiles'' of form caches.  A profile is a simply a list of forms that you can use to rapidly:
*[[#Updating the Cache of a Profile|Update]] the cache for each of the forms in the profile
*[[#Exporting the Cache of a Profile|Export]] the cache, via a mysqldump, for each of the forms in the profile.  This is particularly useful for exporting data from a regional or district office to the national level.
 
This functionality is part of the [[I2CE_Module_List#CachedForms  | Cached Forms modules]] and can be accessed by clicking on the links for '''Configure System''' and then '''Cached Forms'''
 
==Creating A Profile==
The first step is to create a ''profile'' of the forms.  A profile is a list of forms with a short name that you can use to help you identify the list. 
 
 
#Look under '''Create/Edit Profile''' on the ''Cached Forms'' page.  Here make sure "Create a new profile" is selected in the drop-down, and then click the "Edit" button.
#Now type a name for the profile.  It is best to keep it short with limited punctuation such as "nightly_update"
#Now select each of the forms you wish to include in the profile
#Finally, click the "Submit" button at the bottom of the page
 
==Updating the Cache of a Profile==
You can update all of the forms in a profile under '''Cache Forms''' on the ''Cached Forms'' page.
 
#Choose the profile for which you wish to cache forms
#Click the "Cache" button
 
==Exporting the Cache of a Profile==
 
There are two main usages of exporting all of the forms in profile, you can either get all the data, or only the modifications to the data since the last date. Both can be accessed under '''Export Cached Forms''' on the ''Cached Forms'' page.
 
#Choose the profile you wish to export
#Choose to enable bzip2 compression or not
#Optionally select the modification time.
##If you do not set the modification time, you will get all of the data for the forms. The mysqldump will include "DROP TABLE IF EXISTS" and "CREATE" statements for each of the hippo_XXXX tables.  Data is populated via "INSERT" statements
##If you do not set the modification time, you will get all of the data for the forms. The mysqldump will include '''neither'' the "DROP TABLE IF EXISTS" '''nor'' the "CREATE" statement for each of the hippo_XXXX tables.  Data is populated via "REPLACE" statements.
#click the "Export" button


The background process will, in general, only update changed forms in the hippo_XXXXX table.  However, once a certain amount of time (one day by default) has passed, the hippo_XXXXX table is completely dropped and rebuilt.  You can change this time by specifying the value at
'''Note:''' When you export the cache, it does not first update it.  You will need to do this manually.
*/modules/CachedForms/times/recache_time


==Crontab and Command Line Interaction==
For example, you may wish to put an update of the profile "nightly_update"  in your crontab:
  30    1    *    *    *        /usr/bin/php /var/www/ihris-manage/index.php --page=/CachedForms/cache --get=profile=nightly_update
will cause all forms in the 'nightly_update' profile to be update at 1:30am. Putting:
  10    *    *    *    *        /usr/bin/php /var/www/ihris-manage/index.php --page=/CachedForms/cache --get=profile=hourly_update
in your profile will update every form in the 'hourly_update' profile at ten minutes past the hour.


[[Category: Technical Overview]]
[[Category:Developer Resources]]

Latest revision as of 19:05, 1 March 2019

The iHRIS software caches data saved in the database (or XML file or LDAP server) for faster access and the ability to create indices. These caches are used, for example, to populate reports and drop-down lists.


The data for a form XXXXX may be cached into a table hippo_XXXXX. This hippo table can be used for:

Hippo Table Structure

If a form XXXXX has a field YYYYY then the hippo_XXXXX table will have a column `XXXXX+YYYYY.` There is also a column `XXXXX+id` containing the id of the form and a column `XXXXX+parent` containing the parent form, if any.

Cache Times and Command Line

The hippo tables are generated by a background process once a form cache is consider stale. See the Configuring Form Cache Generation Timing document for information on timing for form caches and information on manually creating the form caches from the command line.

To see this tutorial for different versions of the software see the following:


Editing, Exporting and Updating Form Caches Using Profiles

In version 4.0.6 we add the ability to create profiles of form caches. A profile is a simply a list of forms that you can use to rapidly:

  • Update the cache for each of the forms in the profile
  • Export the cache, via a mysqldump, for each of the forms in the profile. This is particularly useful for exporting data from a regional or district office to the national level.

This functionality is part of the Cached Forms modules and can be accessed by clicking on the links for Configure System and then Cached Forms

Creating A Profile

The first step is to create a profile of the forms. A profile is a list of forms with a short name that you can use to help you identify the list.


  1. Look under Create/Edit Profile on the Cached Forms page. Here make sure "Create a new profile" is selected in the drop-down, and then click the "Edit" button.
  2. Now type a name for the profile. It is best to keep it short with limited punctuation such as "nightly_update"
  3. Now select each of the forms you wish to include in the profile
  4. Finally, click the "Submit" button at the bottom of the page

Updating the Cache of a Profile

You can update all of the forms in a profile under Cache Forms on the Cached Forms page.

  1. Choose the profile for which you wish to cache forms
  2. Click the "Cache" button

Exporting the Cache of a Profile

There are two main usages of exporting all of the forms in profile, you can either get all the data, or only the modifications to the data since the last date. Both can be accessed under Export Cached Forms on the Cached Forms page.

  1. Choose the profile you wish to export
  2. Choose to enable bzip2 compression or not
  3. Optionally select the modification time.
    1. If you do not set the modification time, you will get all of the data for the forms. The mysqldump will include "DROP TABLE IF EXISTS" and "CREATE" statements for each of the hippo_XXXX tables. Data is populated via "INSERT" statements
    2. If you do not set the modification time, you will get all of the data for the forms. The mysqldump will include neither the "DROP TABLE IF EXISTS" nor the "CREATE" statement for each of the hippo_XXXX tables. Data is populated via "REPLACE" statements.
  4. click the "Export" button

Note: When you export the cache, it does not first update it. You will need to do this manually.

Crontab and Command Line Interaction

For example, you may wish to put an update of the profile "nightly_update" in your crontab:

 30     1     *     *     *         /usr/bin/php /var/www/ihris-manage/index.php --page=/CachedForms/cache --get=profile=nightly_update

will cause all forms in the 'nightly_update' profile to be update at 1:30am. Putting:

 10     *     *     *     *         /usr/bin/php /var/www/ihris-manage/index.php --page=/CachedForms/cache --get=profile=hourly_update

in your profile will update every form in the 'hourly_update' profile at ten minutes past the hour.