Zymonic Caches

To deliver optimal performance to the end user Zymonic systems employ caching in several places.

= System Option Caching = Since system option values rarely change, all systems options and their values are cached in memory on the Apache process. This enabled quick lookup of system options without having to access the DB.

A side effect of this is that when a system option is changed it might not immediately be picked up until the next Apache process is loaded. The cache can be forcibly cleared by appending to any zymonic url &ZZclear_sys_opt_cache=true, or by clicking the option in the top right menu Clear System Options Cache. This will then force the Apache process to rebuild its cache of system options form the DB.

= DB Caching = Each request to zymonic will load up a new Zymonic::DB object object to handle its connection to the DB. To minimize the number of connections, and be able to reuse existing connections, Zymonic::DB objects thems are cached on the Apache process and reused (when the connection details are the same).

To force any cached Zymonic::DB objects to be cleared the following can be appended to any zymonic url &ZZclear_db_cache=true, or by clicking the option in the top right menu Clear DB Cache. This will immediately destroy any Zymonic::DB objects cached on that Apache process.

In debug files you will see the following debug if a cached Zymonic::DB object is used: "Using cached DB instance: $cache_string"

And if it created a new Zymonic::DB instance then debugs will show: "New DB instance: $cache_string"

($cache_string will be db connection details)

There are several internal caches within Zymonic::DB which will be effected by this.

Run Query Caching
If a call is made to run_query function with cache_key set then any results from the SQL will be cached using that value, and if it exists then the cached value will be returned.

Currently the only places in zymonic systems which use this functionality are:
 * Zymonic::Condition::Permission - getting unique sec_ids from a table
 * Zymonic::Auth::update_permissions - looking up dependent permissions (only if system option cache_permission_dependencies_lookup is set)
 * Zymonic::Auth::check_permissions - looking up permissions for incoming details (currently only called from Zymonic::Condition::Permission and Zymonic::Toolkit::Security)

= Materialized Views = TODO