Alpha4615 / phpMyCache

A PHP library that caches mySQL SELECT queries to the file system
GNU General Public License v2.0
1 stars 1 forks source link

Pass config overrides and other special values at call time #12

Open Alpha4615 opened 10 years ago

Alpha4615 commented 10 years ago

Instead of queryCache having tons of arguments that is growing as features are being thought up, there should be an argument where config values and other special values can be provided in a key-value array. The config values are overridden only for that call.

This should maintain backwards and forwards compatibility.

An example:

$pmc->queryCache("SELECT ...", 3600, array('returnMeta' => true));

This will replace the ignoreCache argument currently in place. ignoreCache, while not a config option, will be accepted in this array as a "special value"

This can be accomplished by cloning the instance's config object and running import(); with that passed array and using that cloned instance in the internal methods.

Be sure that the cloned config object is not a pointer to the internal instance, otherwise the options passed that were intended to be used in that single call will be set into all future calls.