-
Notifications
You must be signed in to change notification settings - Fork 29
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
Feature Request: Add a filter/configuration to disable cache on queries #139
Comments
Makes sense to me. Good idea 👍 With this implemented, the In the meanwhile, look into using // Prevent cache additions
$old = wp_suspend_cache_addition( true );
(...do your things...)
// Restore cache additions to whatever the state used to be
wp_suspend_cache_addition( $old ); Relatedly, this reminds me that Berlin uses |
I went outside and did some exercise, and am coming back with more thoughts. You can tell me truthfully if they are not good ones. 🤣 There are areas of improvement in WordPress itself with how the
All of this is to say, that – I think – if we do this in Berlin that we should add query variables to help influence/control/toggle all of the cache interactions, and not just object/Query reads or writes, and probably not using WordPress core's approaches, because they aren't really all that awesome currently. Up to and including adding our own Thoughts? |
WoW that's a great explanation John, many thanks. I totally agree having a cache class to have all the cache attributes and methods that can be used in all other classes and we can start with the Query one and see how it goes from there. do u think that this cache class should have static methods like Utility class to be easily embedded into other classes or a normal class that somehow can be injected into their constructors? I will invest this weekend trying to think about this new class and the data should be there. |
I know that using cache for queries is very important and makes the process faster but we have a case that we need to disable it for one query.
The case is that we have a code that inserts multiple fake posts on the same request and with
pre_post_update
hook we have our callback to make a query to make sure that we don't have a record with some criteria to do action with it so when the cache is enabled, it inserts the first one and with the second one the query gets the data from the cache.We temporary can solve that by using the following hook
https://github.com/berlindb/core/blob/master/src/Database/Query.php#L871
then use the WP function
wp_cache_flush
but this will flush the whole cache :(I know that you try to eliminate having short circuit filter into the plugin so we may have an argument to disable the cache with default value is false.
If u agree I can start PR for this one.
The text was updated successfully, but these errors were encountered: