Suspend and resume object cache — at Initial Version
|Reported by:||ryan||Owned by:|
We sometimes need to suspend object cache operations, notably during installation and importing. During install we want to know we are working with the raw DB values. During import we want to avoid set/get trips to the cache (especially when using the memcached backend) for a potentially huge number of new objects -- objects that probably won't be requested again. We also want to avoid the overhead of caching imported objects in memory. With big imports we can bust the php memory limit.
In some places, we check if WP_IMPORTING or WP_INSTALLING is set and disable cache sets and gets. Not all cache backends do this however. Instead of references global defines, let's formalized this with two function calls, wp_suspend_cache() and wp_resume_cache(). When the cache is suspended, all cache gets return false and all sets/adds return true without actually setting anything. Deletes should probably still be processed. It is up to the caller to make sure it doesn't do things that would make the cache inconsistent with the DB while the cache is suspended. Given our current model where we usually delete on change and add on read, this shouldn't be a problem.