[wp-trac] [WordPress Trac] #39090: Remove duplicate query from posts page in the admin

WordPress Trac noreply at wordpress.org
Wed Dec 7 16:00:17 UTC 2016


#39090: Remove duplicate query from posts page in the admin
------------------------------------------+-----------------------------
 Reporter:  rodrigosprimo                 |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Users                         |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  performance
------------------------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:   => needs-patch needs-unit-tests
 * focuses:  administration, performance => performance
 * component:  Posts, Post Types => Users
 * milestone:  Awaiting Review => Future Release


Comment:

 @rodrigosprimo Thanks for the patch!

 As written, the patch won't work - it caches queries indefinitely. This
 means that cached data will be returned even after (say) a new user
 registers. So we need some invalidation built in. The strategy we use in
 other query classes is an incrementor hashed with the cache key:

 {{{
 $last_changed = wp_cache_get_last_changed( 'users' );
 $hashed_args = md5( $args );
 $cache_key = "get_users:$hashed_args:$last_changed";
 }}}

 Then, on any action that will result in user query results being different
 (new user creation, user edit, etc), invalidate the cache: `wp_cache_set(
 'last_changed', microtime(), 'users' )`

 This may be a good time to break the user query into two separate queries:
 one for IDs only (which will be cached as described above), and one for
 user objects (which are already separately cached).

 We'll need unit tests demonstrating invalidation in order to move forward.

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


More information about the wp-trac mailing list