I'm trying to think of a simple way to permanently pin a PHP object to memory and then have it available to other more transient objects to message with during their normal job of servicing page requests. I'm still relatively new to Wordpress so maybe I'm making things too complicated ... let me demonstrate through an example what I would want to be able to do:
- Have a UOM (unit of measure) object load up at startup that polls the database for a list of units, the default units, categories of units (e.g., pounds is an
imperial
measurement), conversion rates, etc. - Subsequent service requests that want to use UOM conversions or lookups would simply call the global UOM object (
$UOM->get_measures_for_category ('speed')
). This object would already be in memory and not need to go back to the database to service requests. - An
update()
method on UOM would allow event or timing based triggers to ask for the UOM object to update itself.
This is just one example of where there is a some relatively static set of data that is used regularly by service requests and the repeated querying of the database would be wasteful. Hopefully people are familiar with this pattern and could maybe point me to some examples of how you would do this in a Wordpress/PHP environment.