isset is much faster than array_key_exists. For caches we need to
ensure as much performance as possible. To all null to continue to
be stored and provide correct results, non ttl also now saves in
$this->store[$key][0]. As isset($this->store[$key]) will return
true in all cases.
time() as found in cache::now() can be slow on some platforms and
we shouldn't bother checking it unless needed. It also stops non-ttl
caches paying the ttl price.
Unit tests were adjusted to ensure null is still handled correctly
when we are only using isset.
By holding onto a reference of the global $CFG object we
can be sure that it isn't destroyed before we are done
with it.
This allows for caches to be used within destructors for
purposes such as delayed writes.
The solution to this issue was to make the disabled cache factory
return a proper cache writer object when requested rather than a
disabled cache object.
This only changes things when CACHE_DISABLE_ALL has been defined.
Issues:
1. Fix setType calls
2. Changing from default to all and editing again, default is still selected.
3. Uncheck all options causes error.
4. Doesn't seem to be restricting based upon option.
5. Picked all and got coding error with the database thing.
6. Bad title: https://github.com/samhemelryk/moodle/commit/wip-MDL-37500-m25#L1R157
7. Amend comments - should only be removed once 2.5 is the minimum version for an upgrade.
8. Document the defaultsharing option.
Outcomes:
1. Fixed - copy paste error.
2. Fixed - mforms was applying the default value despite a value being provided. A quirk of elements with array names.
3. Fixed - validation now requires at least one option to be selected.
4. Fixed - issue rose from definitions not being re-parsed. cache/admin.php now reparses the first time a user visits the page.
5. Fixed - better purging of definitions when working with them anonymously. Unit test added.
6. Fixed - new string added and used.
7. Fixed - comments amended.
New issue to address parsing of definitions during upgrade.
New issue to add debugging notice if definition sets only one possible sharing option and that option is user input.
get_plugin_list was calling clean_param($pluginname, PARAM_PLUGIN) a
lot (600+ times per page), and that is much slower than you would guess.
A specific function for this case, (which we then also use from
clean_param) is a performance win.