WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#41847 closed enhancement (duplicate)

Add caching to WP_User_query

Reported by: spacedmonkey Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Users Keywords: has-patch
Focuses: performance Cc:

Description

Calls to WP_User_Query can be very expensive, as sites with public registration can have many users. The WP_Comment_Query, WP_Site_Query and WP_Network_Query classes all have caching enabled. All these classes, have a list of object ids and number of found items in cache. This caching should be added to user queries.

Attachments (1)

41847.diff (6.9 KB) - added by spacedmonkey 3 years ago.

Download all attachments as: .zip

Change History (4)

@spacedmonkey
3 years ago

#1 @spacedmonkey
3 years ago

First patch adds basic caching. It add cache invalidation for user meta, adding users to blogs and CRUD functions for users.

This changes all queries to be ids, get the whole user object. Then for fields queries, just pick off the fields out of the WP_User object that you want.

Other big change is to the cache_users function. This function is very similar to _prime_<type>_cache function. I have added new param to cache_users of $update_meta_cache to optionally prime user meta caches.

#3 @spacedmonkey
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #40613.

Note: See TracTickets for help on using tickets.