bu-navigation
bu-navigation copied to clipboard
Introduce a caching layer in `bu_navigation_get_posts`
https://trello.com/c/eU9qfTAa/30-ca-6-bu-navigation
This approach leverages keys stored in a new cache group - bu-navigation-persistent
- as bu-navigation
is set as non-persistent.
A copy of the last_changed
cache key value from WP core is stored along with the results of the query made in the bu_navigation_get_posts
function. This is stored with a key that uses the arguments passed to the function, JSON encoded and wrapped in md5
, so that multiple unique calls to the function will retrieve their respective results.
If the last_changed
value stored with the results of the query don't match the current WP core value of last_changed
, the cache for that call is reset.
WP core's last_changed
key is also reset whenever changes to the menu are saved.
I think this approach makes sense, but I appreciate that my understanding of the plugin as a whole may not be complete enough, and I could be missing something.