cache:clear
Clears specific cache keys or flushes entire cache connections.keys(optional, array) - Cache keys to delete in the formatconnection:key
-f, --flush- Flush all cache connections (destructive operation)
Clearing Specific Keys
Delete individual cache keys by specifying the connection and key name:Use the wildcard
* as the key name to flush all keys in a specific connection.Flushing All Cache
Flush all cache connections defined in your configuration:Supported Cache Drivers
Thecache:clear command supports different operations based on the cache driver:
Redis
Redis
Operations:
- Check if key exists:
EXISTS key - Delete key:
DEL key - Flush connection:
FLUSHDB
Memcached
Memcached
Operations:
- Get key to check existence
- Delete key:
delete(key) - Flush connection:
flush()
Local/File-based
Local/File-based
Operations:
- Deletes cache files from
app/logs/cache/*.log
Progress Indicator
When clearing multiple keys, a progress bar shows the operation status:Cache Configuration
Cache connections are defined in yourconfig/cache.php file:
Usage Examples
Clear Route Cache
Clear Multiple Middleware Caches
Flush Specific Connection
Clear Development Cache
Selective Cache Clear
Common Cache Keys
Depending on your Aeros application configuration, common cache keys might include:cache.routes- Cached application routescache.config- Configuration cachecache.middlewares- Middleware cachecache.providers- Service provider cachesession.*- Session datauser.*- User-specific cache
Error Handling
The command provides detailed error messages:Key not found
Key not found
Connection not found
Connection not found
config/cache.php.Unsupported driver
Unsupported driver
Best Practices
Development
Use
--flush frequently during development to ensure fresh cacheProduction
Clear specific keys instead of flushing to avoid performance impact
Deployments
Clear cache after deploying configuration or route changes
Testing
Flush cache before running test suites for consistent results
Cache in Application Lifecycle
Therun:app command automatically checks cache connectivity:
cache:clear to troubleshoot connection issues.
Next Steps
CLI Overview
Learn about other CLI commands
Cache Usage
Learn how to use cache in your application