I want override command cache:flush. while execute this php bin/magento cache:flush i want to execute my custom module code. can i do? please guide me on this.
Note: i'm try to use in magento 2.4.5-p1
For your requirement, there are 2 ways.
If you want to create event observer, then create like this :
<event name="adminhtml_cache_refresh_type">
<observer name="youobservername" instance="Vendor\Extension\Observer\YourcustomerObserverFile"/>
</event>
If you want plugin, then cache:flush
command execute code from this methods.
\Magento\Backend\Controller\Adminhtml\Cache\FlushAll::execute()
method.
so try to create that class plugin.