[wp-trac] [WordPress Trac] #23059: if object cache entry for last_changed in term and comments groups is purged, it invalidase too many cached items

WordPress Trac noreply at wordpress.org
Wed Dec 26 14:10:33 UTC 2012


#23059: if object cache entry for last_changed in term and comments groups is
purged, it invalidase too many cached items
-----------------------------+--------------------------
 Reporter:  mark-k           |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Cache
  Version:  3.5              |   Severity:  normal
 Keywords:                   |
-----------------------------+--------------------------
 Some context to explain the issue - I was trying to be smart and cache
 menu generation by setting my own object temporary object caching just
 before the outputing the menu and saving the resulting cache to an option.
 On next page load I populated the cache for the option before outputting
 the menu.
 It didn't work.

 After some digging I found out that the cache key for the menu terms
 composed as "get_terms:$key:$last_changed" and that the $last_changed part
 was different in every run. So I went an looked how it is set and
 everything became clear


 {{{
         $last_changed = wp_cache_get('last_changed', 'terms');
         if ( !$last_changed ) {
                 $last_changed = time();
                 wp_cache_set('last_changed', $last_changed, 'terms');
         }

 }}}

 Because I am running without object cache before the menu code is executed
 $last_changed changes every run.

 This might be an edge case, but IMO it means that whenever 'last_changed'
 is purged/garbage collected all the terms related cached values are
 practically invalidated as well.

 I really don't understand why the value is part of the cache key at all,
 but if it has to be shouldn't it be stored in a less volatile storage?

 related #22024. It is closed but I think that change also doesn't handle
 well the situation where last_changed for comments is purged

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23059>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list