Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace slugs qts_page_request cache with transient #1182

Merged
merged 1 commit into from
Jun 6, 2022

Conversation

herrvigg
Copy link
Collaborator

@herrvigg herrvigg commented Jun 6, 2022

The WP cache is not appropriated for very short term storage.
Moreover a wrong value could have been stored between different requests.
Replace the cache call with a transient expiring after 30s.
Delete the transient right after reading it.
Rename it to qtranslate_slugs_matched_page.

The WP cache is not appropriated for very short term storage.
Moreover a wrong value could have been stored between different requests.
Replace the cache call with a transient expiring after 30s.
Delete the transient right after reading it.
Rename it to `qtranslate_slugs_matched_page`.
@herrvigg herrvigg force-pushed the slugs-transient-match branch from d6b24ba to 621a034 Compare June 6, 2022 16:54
if ( ! $page ) {
return $query;
}
$id = $page->ID;
$cache_array = array( $page );
update_post_caches( $cache_array, 'page' ); // caching query :)
wp_cache_delete( 'qts_page_request' );
update_post_caches( $cache_array, 'page' );
Copy link
Collaborator Author

@herrvigg herrvigg Jun 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this patch, but I'm not sure about this update_post_caches and all similar updates in QTS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's really needed, also because we are not modifying the post objects here. But I don't think it has anything to do with the caching query :) comment btw.
This is calling eventually wp_cache_add_multiple, so I think is not updating anything most of the time (it will only update if those keys do not exist already).
We may just add a comment to double check later or remove the calls now...

@spleen1981 spleen1981 merged commit 9fea88a into master Jun 6, 2022
@spleen1981 spleen1981 deleted the slugs-transient-match branch June 6, 2022 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants