Suspend and resume object cache
|Reported by:||ryan||Owned by:|
Description (last modified by ryan)
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 referencing global defines, let's formalize 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.
Change History (22)
- Keywords has-patch added; cache removed
- Milestone set to Awaiting Review
- Resolution wontfix deleted
- Status changed from closed to reopened
- Component changed from General to Cache
- Keywords 3.2-early added
- Milestone changed from Awaiting Review to Future Release