VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/10.3-cache-management-commands

⇱ Cache Management Commands | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

Cache Management Commands

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.

Overview

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 maho34
  • cache:disable: Disables all cache types maho35
  • cache:flush: Flushes all cached data from the configured storage maho36
  • cache:minify:flush: Flushes minified CSS/JS assets and their runtime tracking maho37

Command Registration

All 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

Command Architecture

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

cache:enable and cache:disable Commands

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

Implementation Logic

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:

Sources: lib/MahoCLI/Commands/BaseMahoCommand.php20-24 app/code/core/Mage/Adminhtml/controllers/CacheController.php84-126 app/code/core/Mage/Core/etc/config.xml114-147

cache:flush Command

The cache:flush command performs a full invalidation of the configured cache backend and triggers internal cleanup events.

Execution Flow

  1. Initialization: Calls initMaho() to bootstrap the environment lib/MahoCLI/Commands/BaseMahoCommand.php20-24
  2. Backend Flush: Calls Mage::app()->getCache()->flush(). This clears the storage medium (e.g., Filesystem, Redis, SQLite) associated with the application app/code/core/Mage/Adminhtml/controllers/CacheController.php51
  3. Event Dispatch: Dispatches the adminhtml_cache_flush_all event app/code/core/Mage/Adminhtml/controllers/CacheController.php52

This 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

cache:minify:flush Command

The cache:minify:flush command targets the specialized minification cache used for CSS and JS assets.

Minification Architecture

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

Flushing Process

When this command is executed, it invokes the cleanup logic defined in the Adminhtml controller app/code/core/Mage/Adminhtml/controllers/CacheController.php208-226:

  1. Helper Execution: Calls Mage::helper('core/minify')->clearCache(), which removes the physical files from the mahominify directory app/code/core/Mage/Adminhtml/controllers/CacheController.php211
  2. Event Dispatch: Dispatches the clean_minified_cache_after event app/code/core/Mage/Adminhtml/controllers/CacheController.php212

Title: 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

Comparison of Cache Operations

OperationCommandEntity ImpactedMechanism
Enablecache:enableCache Options ConfigurationMage::app()->saveUseCache() app/code/core/Mage/Adminhtml/controllers/CacheController.php98
Disablecache:disableCache Options ConfigurationMage::app()->saveUseCache() app/code/core/Mage/Adminhtml/controllers/CacheController.php122
Flush Storagecache:flushConfigured Cache BackendMage::app()->getCache()->flush() app/code/core/Mage/Adminhtml/controllers/CacheController.php51
Flush Minifycache:minify:flushpublic/media/mahominify/Mage::helper('core/minify')->clearCache() app/code/core/Mage/Adminhtml/controllers/CacheController.php211
Refresh TypeN/A (Admin only)Specific Cache TagsMage::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