MDL-39456 cachestore_file: added reference to global $CFG

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.
Temp commit