[wp-hackers] Two loops on one page?

Ryan Boren ryan at boren.nu
Wed Nov 10 00:06:02 UTC 2004


On Tue, 2004-11-09 at 17:16 -0500, Owen Winkler wrote:
> Ryan Boren wrote:
> > update_post_caches() needs to be fixed.  It would be nice if it merged
> > each run cleanly into the category cache rather than obliterating the
> > previous cache.  Anyone wanna fix it?
> 
> Maybe...
> 
> Intuition says that there must be more to it, but this small change is 
> working for me.

That should work.  The index number in the array shouldn't really matter
since we usually foreach over it.

> I wonder, though, in what case would the cache be incomplete that it 
> would need to merge like this?  It seems as though if a category cache 
> exists for a specific post ID at all, that it would be implicitly 
> complete.  If so, then a better solution would check whether the cache 
> exists and then not suffer the database hit if it doesn't have to.

I meant the cache should have all of the posts collected so far across
all queries. The original query_posts() and subsequent get_posts
()/query_posts() can have different sets of posts.  The cache should be
a union of all of these sets.  And, yes, the category cache for a given
post ID should be implicitly complete.

Ryan




More information about the hackers mailing list