[wp-trac] [WordPress Trac] #21760: get_term_by() calls are not cached

WordPress Trac noreply at wordpress.org
Sat Oct 11 03:25:44 UTC 2014


#21760: get_term_by() calls are not cached
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |       Owner:  wonderboymusic
     Type:  enhancement     |      Status:  assigned
 Priority:  normal          |   Milestone:  4.1
Component:  Taxonomy        |     Version:  2.3
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:  has-patch commit 4.1-early => has-patch
 * milestone:  Future Release => 4.1


Comment:

 [attachment:21760.2.patch] does the following:

 - refresh for current trunk (whitespace was preventing from applying)
 - I like tollmanz's suggestion
 https://core.trac.wordpress.org/ticket/21760#comment:48 that cached values
 get returned through the filters, so it's implemented here
 - I also think he's correct that cache invalidation preferences should be
 respected in `update_term_cache()`, so it's in there too
 - The change in `update_term_cache()` that forces 'last_changed' to be
 incremented caused a failing test related to `get_terms()`. It turns out
 that `get_terms()` is calling `update_term_cache()` whenever you call it
 with 'fields=all'. This looks like a bug to me, since the terms are
 properly cached after the queries are run later in the function (and that
 bit of code goes back to Ye Olden Days of WP). I've removed it.

 > With some caching systems, the eviction policy is a bit problematic for
 an incrementor system (e.g., APC fills the cache until full, them dumps
 everything). We need to be really careful about how we do this to make
 sure it will consistently work across object caches. Ideally, when we
 change the incrementor, we delete the old one or overwrite it.

 FWIW, I think this is only the default behavior. I'm pretty sure that if
 you set a non-zero ttl, only expired items are dumped when the cache
 fills. More generally, while I totally agree that we should constantly be
 mindful of the realities of various caching systems, it's also reasonable
 to expect that the people implementing those systems will be cognizant of
 the requirements of the particular backend they've chosen, and will
 configure it accordingly.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/21760#comment:52>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list