Make WordPress Core

Opened 11 years ago

Last modified 7 years ago

#5389 closed defect (bug)

Suspend and resume object cache — at Version 2

Reported by: ryan Owned by:
Milestone: 3.3 Priority: normal
Severity: normal Version: 2.5
Component: Cache API Keywords: has-patch
Focuses: Cc:

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 (3)

#1 @markjaquith
11 years ago

Cool by me.

#2 @ryan
11 years ago

  • Description modified (diff)

10 years ago

Note: See TracTickets for help on using tickets.