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

Handling custom configuration files #95

Open mvenghaus opened 3 years ago

mvenghaus commented 3 years ago

Hey Vinai,

I have some custom configuration files and I want your tool to handle them without rebuilding the source.

A rules config file would be nice .. maybe something simple like that: vendor/bin/cache-clean.js -w --custom-rules=rules.json

{
  "/etc/custom\\.xml$": ["config", "block_html"]
}

Or is it already possible?

Regards Marcus

Vinai commented 3 years ago

Hi, thanks for opening the issue! This is something I've been thinking about, too. So far I haven't had to cache my custom configuration files, but it certainly is a use case.

My idea was to allow a file called etc/cache-clean-rules.json (or maybe .edn or .js) to be added to modules. In this file it would be possible to declare three types of mappings:

1.) file name regex to cache types (as in your example) 2.) file name regex to cache IDs 3.) file name regex to a callback that returns the cache IDs to clean for a given file

The underlying idea is to keep cache cleans granular so full config cache cleans can be avoided if possible. Do you have any thoughts on this?

mvenghaus commented 3 years ago

Hi,

that sounds like a plan .. I'm in :)

  1. Would be the affected file a parameter in that case?