Thank you.
The cache plugin does not itself cache any queries. Instead other plugins or WP itself must decide to cache a query.
The plugin installs an object-cache that makes the WP object cache persistent.
So can you say when scripts/queries fail?
I have written a script for retrospective data collection (user activities and etc). It takes a long time to execute the script (contains a lot of db queries), so it runs in the background in chunks. It works fine without APCu plugin, but when the plugin is active at some point it just stops executing with no error messages.
One more problem. I have installed the stage and prod environments on the same account of a shared hosting, and there is a conflict when both environments use the APCu plugin, which causes the server to freeze. However this is not a big problem, I just turn off the plugin on one of the environments.
You can set WP_APCU_KEY_SALT in each wp-config.phpto something that is unique for each install (like an md5 of the MySQL host, database, and table prefix). That could fix the issue with multiple installs.
Is that script in a plugin or theme?
You can use the APCu groups tag to see what data is in the APCu cache.
If it is not stored there you probably have another issue but it is difficult to tell from here.
Thanks for the WP_APCU_KEY_SALT. I’ll try. Btw I think you can make it unique automatically, isn’t it?
That’s my custom plugin. So there is no way to disable caching for the part of a code, right?
How can I use the APCu groups tag? Tell me more please.
well you can try the wp_suspend_cache_addition command in your plugin, turn it off on start, turn it back on when process is finished – might help.
The APCu tab in the plugin shows all APCu keys. You should be able to find your query there, if it is stored my WP – otherwise it should not have any effect on your script.
you can also experiment with the hook you use to run your script.
I’m using ‘wp_suspend_cache_addition’ already. And I also tried to use this function (doesn’t help): https://developer.ww.wp.xz.cn/reference/functions/wp_using_ext_object_cache/
I noticed that my script crashes when it hits the APCu memory limit (32mb). My script goes through all the orders made in woocommerce and this is visible on the APCu tab in the plugin. Is it possible to stop storing all these queries?
would be interesting to see the keys, you could flush the cache after each query, using apcu_delete.
also if you query the db directly, queries should not be cached, as WP does not know anything about it.
I’m using native WC and WP methods.
Popular keys: posts, post_meta, post-queries, ld_lesson_tag_relationships, term_meta, ld_topic_tag_relationships, ld_lesson_category_relationships.
I also tried to apcu_clear_cache() before and after every chunk of queries but it doesn’t help. 🙁
Try
global $wp_object_cache;
$wp_object_cache->flush();
What error do you get?
Some progress:
The problem with the wp_schedule_single_event(time(), 'run_long_task'). It returns true, but after that, sometimes the scheduled action doesn’t run. And it happens when the APCu plugin is active.
Use atec-debug CRON tab, you can see your cron and countdown.
Also, how is the traffic on your page? Cron only runs when page is visited not when admin is logged in.
Fatal error: Uncaught Error: syntax error, unexpected ‘|’, expecting ‘{‘
in /…/wp-content/plugins/atec-debug/includes/atec-wpd-dashboard.php on line 46
Call stack:
atec_wpd()
WP_Hook::apply_filters()
WP_Hook::do_action()
do_action()