mage2tv / magento-cache-clean

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

Add example how to start watcher from code instead of CLI #61

Closed Vinai closed 4 years ago

Vinai commented 4 years ago

In Slack from @paales:

One thing i’d like if it were possible to integrate in our current webpack dev server. So an example how to start it up by code instead of cli would be nice.

Vinai commented 4 years ago

I've added an experimental API with exported functions to be called from custom code in release 1.0.24. More info can be found here: https://github.com/mage2tv/magento-cache-clean/blob/master/doc/using-via-code.md

I would appreciate some feedback how it works out for you. Thanks!

paales commented 4 years ago

Very cool!

Vinai commented 4 years ago

Note to self: also add function exports for clearing cache by tags or cache ids.

Vinai commented 4 years ago

I've decided to remove the stateful external API. Instead of set_base_dir, set_log_level and watch, I'll only expose a single method

watch(baseDir, logLevel).

Any state will be managed internally. This will make future internal changes simpler.

I'll also add methods to clear all caches, or clear by cache tag or cache id:

cleanTags(baseDir, ...tags) cleanIds(baseDir, ...ids] cleanAll(baseDir)

Vinai commented 4 years ago

API and documentation updated, will be reflected in the upcoming release 1.0.25.

https://github.com/mage2tv/magento-cache-clean/blob/master/doc/using-via-code.md

Vinai commented 4 years ago

I'm happy with the new API and the documentation. If there is anything I could improve, please let my know by opening another issue.