This document is for CakePHP's development version, which can be significantly different from previous releases.
You may want to read current stable release documentation instead.

Page Contents

CounterCache Tool

The CounterCacheCommand provides a CLI tool for rebuilding the counter caches in your application and plugin models. It can be used in maintenance and recovery operations, or to populate new counter caches added to your application.

bin/cake counter_cache --assoc Comments Articles

This would rebuild the Comments related counters on the Articles table. For very large tables you may need to rebuild counters in batches. You can use the --limit and --page options to incrementally rebuild counter state.

bin/cake counter_cache --assoc Comments --limit 100 --page 2 Articles

When limit and page are used, records will be ordered by the table’s primary key.

Added in version 5.2.0.