Make WordPress Core

Opened 7 years ago

Closed 16 months ago

Last modified 15 months ago

#41131 closed enhancement (fixed)

Add caching to get_adjacent_post

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.2 Priority: normal
Severity: normal Version: 2.5
Component: Posts, Post Types Keywords: has-patch has-unit-tests dev-feedback needs-dev-note
Focuses: performance Cc:


Add caching to the get_adjacent_post function. Current the caching in the function is not persistent.

Attachments (2)

41131.patch (3.8 KB) - added by spacedmonkey 7 years ago.
41131.2.patch (3.8 KB) - added by spacedmonkey 7 years ago.

Download all attachments as: .zip

Change History (24)

7 years ago

#1 @spacedmonkey
7 years ago

  • Keywords has-patch has-unit-tests dev-feedback added

Patch added with tests. It is pretty simple patch.

#4 @spacedmonkey
7 years ago

In 26937#comment:57 @wpdavis has a valid point about caching. It seems like we have been down the road of trying to use WP_Query in this function. This patch adds caching to an expensive sql query. This ticket should progress ahead of #26937

#5 @johnbillion
7 years ago

  • Owner set to johnbillion
  • Status changed from new to reviewing

#6 @johnbillion
5 years ago

  • Owner johnbillion deleted

#7 @spacedmonkey
20 months ago

  • Milestone changed from Awaiting Review to 6.2

#8 @spacedmonkey
20 months ago

  • Owner set to spacedmonkey

@spacedmonkey commented on PR #3366:

18 months ago

Is it possible to use WP_Query if the filters become wrappers for their Query equivalents? It might require closures but has the advantage of using the low level cache rather than a duplicate cache.

I thought that using WP_Query would be impossible. But I worked something out.

This ticket was mentioned in PR #3743 on WordPress/wordpress-develop by @spacedmonkey.

18 months ago

Trac ticket:

@spacedmonkey commented on PR #3734:

17 months ago

Closing favour of #3366

@spacedmonkey commented on PR #3743:

17 months ago

Closing in favour #3366

@spacedmonkey commented on PR #3366:

16 months ago

@mukeshpanchal27 Update messages. Your approval, I will commit this change.

#16 @spacedmonkey
16 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55085:

Posts, Post Types: Use persistent caching in get_adjacent_post function.

The function get_adjacent_post cached the results of database query in the cache group counts. This is a none persistent group and meant cache would not persist on the next request. Change cache to save to the posts cache group. Cache invalidation is done by using get last changed value of the posts and terms group as a salt for the cache key.

Props spacedmonkey, peterwilsoncc, johnbillion, boonebgorges, mukesh27, dd32.
Fixes #41131.

#18 @spacedmonkey
15 months ago

  • Keywords needs-dev-note added

#19 @milana_cap
15 months ago

@spacedmonkey, do we have a volunteer to write the Dev note?

#20 @milana_cap
15 months ago

  • Keywords has-dev-note added; needs-dev-note removed

#21 @milana_cap
15 months ago

  • Keywords needs-dev-note added; has-dev-note removed

#22 @flixos90
15 months ago

Drafted a note for this to be included in the Field Guide's notes section, as shared in

Note: See TracTickets for help on using tickets.