Open Chrico opened 5 years ago
@Chrico Partial flush is probably hard/impossible to pull off because it's an extremely backend-specific problem. Ultimately, we can't do what Stash can't do, and $pool->clear()
is all there is.
However, wp_schedule_event
sounds reasonable, especially since you mention it's in a large multisite, where the backend might be slow and eating into the max_execution_time
more than welcome. So deferring the cache flush to a more or less isolated call sounds like it could help here.
Now that we're performing recurring purge tasks, the FileSystem-driver should clean up after itself and flushing should be possible even from the admin bar. Can you maybe share your experiences after some time on v3.1.0 of WP Stash, @Chrico ?
wp_schedule_single_event
would still be a way to gain a couple of extra seconds on regular installs and ensure the task can run forever on more sophisticated installs. But the obvious downside is that there is no (immediate) feedback about whether (or when) the task is actually executed.
We could still use the wp_schedule_single_event
and showing a admin notices when the job is still running (setting an option when the job start, which will be removed afterwards).
But #14 should have fixed that, even if we invalidate cache objects which shouldn't be invalidated automatically.
showing a admin notices when the job is still running (setting an option when the job start, which will be removed afterwards).
My thoughts exactly. I'm just hesitant to add all this extra logic when it may not really be needed in the end. The only thing that really bugs me now is that if it happens, we get a white screen of death with a 500. Maybe a good first step would be to turn this into an AJAX or REST call? Then we could at least handle this gracefully
Hm.. We could use wp_next_scheduled
instead of an option to check if a cache flush is scheduled. If there is a job, we display a notice.
When purging the WP-Stash-Cache via Backend (AdminBar) in a large Multisite, i can see following error message:
\Stash\Driver\FileSystem
The default timeout of php should be either set to 0 (endless) or better, we should purge the cache partially in background via e.G. Cron by splitten up the folder into multiple Crons to delete those.