[wp-hackers] Best way to do user caching

Jeremy Clarke jer at simianuprising.com
Sun Jun 13 15:43:30 UTC 2010


On Fri, Jun 11, 2010 at 4:29 PM, Simon Blackbourn <piemanek at gmail.com>wrote:

>
> Michael Pretty suggested using the cache_users function (new in 3.0). I've
> now incorporated this into my site but thought I'd write to the list a) to
> check if this is the best way to do it, and b) so anyone else can use the
> code if it's helpful to them.
>

Haven't seen it before but after looking at the cache_users() function it
seems like that is a good way to get only the users you'll need for the
upcoming loop.

FWIW what this situation really calls for is the missing get_users()
function, which should let you fetch all users or a subset as defined by a
role, post count etc. In many cases users are like wp_options, and you'd be
better off doing one big call that loaded all users into the cache than
worrying about individual database calls or the specific users you'll be
needing for this page.

-- 
Jeremy Clarke
Code and Design | globalvoicesonline.org


More information about the wp-hackers mailing list