![]() |
VOOZH | about |
This document covers the CLI commands for managing Maho's cache system. These commands provide functionality to enable, disable, and flush cache types from the command line. For details about the underlying cache system architecture and cache types, see Caching System. For general CLI architecture, see CLI Architecture.
Maho provides four cache management commands that allow administrators to control the cache system without accessing the admin panel. These commands manipulate cache settings and interact with the application's cache model to flush data.
The cache management commands are:
cache:enable: Enables all cache types maho34cache:disable: Disables all cache types maho35cache:flush: Flushes all cached data from the configured storage maho36cache:minify:flush: Flushes minified CSS/JS assets and their runtime tracking maho37All cache commands are registered in the main CLI entry point maho. They are discovered and added to the Symfony Console application during the bootstrap process. The maho script explicitly adds the core cache commands before performing discovery for extension-provided commands maho34-37
Title: Cache Command Registration Architecture
Sources: maho20-37 composer.json111-114
All cache management commands extend MahoCLI\Commands\BaseMahoCommand, which provides the initMaho() method to bootstrap the Maho environment in an administrative context by registering the isSecureArea flag and initializing the admin app lib/MahoCLI/Commands/BaseMahoCommand.php20-24
Title: Cache Command Class Hierarchy
Sources: lib/MahoCLI/Commands/BaseMahoCommand.php18-35 lib/MahoCLI/Commands/CacheFlush.php1-15 lib/MahoCLI/Commands/CacheEnable.php1-15 maho34-37
These commands toggle the operational state of Maho's cache types. They perform direct updates to the cache configuration, mirroring the mass actions available in the Admin UI. Cache types include Configuration, Layouts, Blocks HTML, Translations, Collections Data, and Icons app/code/core/Mage/Core/etc/config.xml116-146
Both commands call initMaho() to ensure the admin application scope is loaded lib/MahoCLI/Commands/BaseMahoCommand.php23
The behavior corresponds to the following logic in Mage_Adminhtml_CacheController:
massEnableAction, which iterates through cache types and sets their status to 1 in the configuration via Mage::app()->saveUseCache($allTypes) app/code/core/Mage/Adminhtml/controllers/CacheController.php84-102massDisableAction, which sets status to 0 and cleans the specific cache types using Mage::app()->getCache()->cleanType($code) app/code/core/Mage/Adminhtml/controllers/CacheController.php107-126Sources: lib/MahoCLI/Commands/BaseMahoCommand.php20-24 app/code/core/Mage/Adminhtml/controllers/CacheController.php84-126 app/code/core/Mage/Core/etc/config.xml114-147
The cache:flush command performs a full invalidation of the configured cache backend and triggers internal cleanup events.
initMaho() to bootstrap the environment lib/MahoCLI/Commands/BaseMahoCommand.php20-24Mage::app()->getCache()->flush(). This clears the storage medium (e.g., Filesystem, Redis, SQLite) associated with the application app/code/core/Mage/Adminhtml/controllers/CacheController.php51adminhtml_cache_flush_all event app/code/core/Mage/Adminhtml/controllers/CacheController.php52This CLI behavior is identical to the flushAllAction in the Mage_Adminhtml_CacheController app/code/core/Mage/Adminhtml/controllers/CacheController.php48-55
Sources: app/code/core/Mage/Adminhtml/controllers/CacheController.php48-55 lib/MahoCLI/Commands/BaseMahoCommand.php20-24
The cache:minify:flush command targets the specialized minification cache used for CSS and JS assets.
Maho uses Mage_Core_Helper_Minify to process frontend assets. Minified files are stored in public/media/mahominify app/code/core/Mage/Core/Helper/Minify.php19 The system uses file locking during the minification process via flock to prevent race conditions when multiple processes attempt to minify the same source app/code/core/Mage/Core/Helper/Minify.php158-164
Minification is applied to skin_css, js, skin_js, and js_css item types in the document head for non-admin requests app/code/core/Mage/Page/Block/Html/Head.php111-121
When this command is executed, it invokes the cleanup logic defined in the Adminhtml controller app/code/core/Mage/Adminhtml/controllers/CacheController.php208-226:
Mage::helper('core/minify')->clearCache(), which removes the physical files from the mahominify directory app/code/core/Mage/Adminhtml/controllers/CacheController.php211clean_minified_cache_after event app/code/core/Mage/Adminhtml/controllers/CacheController.php212Title: Minification Cache Entity Association
Sources: app/code/core/Mage/Core/Helper/Minify.php17-19 app/code/core/Mage/Adminhtml/controllers/CacheController.php208-226 app/code/core/Mage/Page/Block/Html/Head.php111-121
| Operation | Command | Entity Impacted | Mechanism |
|---|---|---|---|
| Enable | cache:enable | Cache Options Configuration | Mage::app()->saveUseCache() app/code/core/Mage/Adminhtml/controllers/CacheController.php98 |
| Disable | cache:disable | Cache Options Configuration | Mage::app()->saveUseCache() app/code/core/Mage/Adminhtml/controllers/CacheController.php122 |
| Flush Storage | cache:flush | Configured Cache Backend | Mage::app()->getCache()->flush() app/code/core/Mage/Adminhtml/controllers/CacheController.php51 |
| Flush Minify | cache:minify:flush | public/media/mahominify/ | Mage::helper('core/minify')->clearCache() app/code/core/Mage/Adminhtml/controllers/CacheController.php211 |
| Refresh Type | N/A (Admin only) | Specific Cache Tags | Mage::app()->getCache()->cleanType($type) app/code/core/Mage/Adminhtml/controllers/CacheController.php138 |
Sources: app/code/core/Mage/Adminhtml/controllers/CacheController.php48-226 app/code/core/Mage/Core/Helper/Minify.php19