New global Object Cache #780

Merged
merged 1 commit into from Apr 12, 2015

Projects

None yet

2 participants

@f0o
Member
f0o commented Apr 12, 2015

This approach actually caches the DB-lookups and makes use of a lazy-load inspired way of loading all the data.

The old object-cache.inc.php fired a load of queries to the DB and defined a set of local variables with their results. Most of the queries made aren't always used, this slows down page load in some cases.

The proposed PR uses an instruction file located at includes/caches/<object-name>.inc.php to obtain a list of queries to perform.
The code stores values from the DB in the $GLOBALS array to cache them, This way the actual instance of the Object can be discarded and re-created but the cached data remains and wont result in a additional DB-Query.
The code also only Queries the DB if no shared cache exists and only Queries explicitly for the requested value instead of all at once.

This is a Drop-In-Replacement. The Class acts like an Array. It is possible to overlay local values, these are not traversed into the shared-cache and thus wont affect other code throughout the application.

Request for Comment :)

@laf laf merged commit 6e1e730 into librenms:master Apr 12, 2015

1 check passed

Scrutinizer 1 new issues, 6 updated code elements
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment