mage2tv / magento-cache-clean

A faster drop in replacement for bin/magento cache:clean with file watcher
BSD 3-Clause "New" or "Revised" License
527 stars 61 forks source link

Warning When Cache Is Disabled #71

Closed sprankhub closed 4 years ago

sprankhub commented 4 years ago

There are or at least were bugs in the M2 core, which lead to the issue that caches are disabled during certain tasks like setup:upgrade. Hence, I propose that the cache clean tool shows a warning whenever the cache is disabled. I would love to have this warning any time even when the tool is already running, but that warning may also be helpful if it is just shown on startup.

I know that this issue is not really cache-clean-tool-related. However, the cache clean tool is all about developer happiness and this would really help IMHO.

Anyway, it is just an idea. Feel free to close if you think it does not fit.

Vinai commented 4 years ago

I like it! The tool could definitely check the cache types settings in app/etc/env.php. Do you think the warning should be displayed only if all caches are disabled? Or any cache-type? Maybe display the warning during startup if any cache type is disabled, and every time if all are disabled? What do you think?

sprankhub commented 4 years ago

That sounds like the best solution to me, yes! Thanks!

Vinai commented 4 years ago

I've got a first version done, but I don't want to roll a release yet. So far I've only ever shelled out to PHP to read the Magento app/etc/env.php configuration at startup. But after that the values are memoized, so changes when caches are being disabled are not picked up. In the current commit I'm only memoizing the settings for 45 seconds. But this means that changes , e.g. if caches are enabled, are not picked up immediately either. So the warning is still shown, even if the underlying issue is already fixed. My plan is now to tie the memoization of the env.php to the file modification time, instead of a time-based expiration. To avoid reading the file mtime every time the config is used, I want to memoize that for 10 seconds.

This means, that if there is activity in the codebase (e.g. development is ongoing):

Any changes to the settings would be picked up in 10 or less seconds. I hope this will minimize expensive calls to PHP and strike a good balance between.

sprankhub commented 4 years ago

Nice!

Vinai commented 4 years ago

Implemented in release 1.0.23

sprankhub commented 4 years ago

Thanks Vinai!