Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions en/appendices/5-2-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Behavior Changes
New Features
============

Console
-------

- The ``cake counter_cache`` command was added. This command can be used to
regenerate counters for models that use ``CounterCacheBehavior``.

ORM
---

Expand Down
1 change: 1 addition & 0 deletions en/console-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ CakePHP Provided Commands

console-commands/cache
console-commands/completion
console-commands/counter-cache
console-commands/i18n
console-commands/plugin
console-commands/schema-cache
Expand Down
24 changes: 24 additions & 0 deletions en/console-commands/counter-cache.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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.

.. code-block:: console

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.

.. code-block:: console

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.

.. versionadded:: 5.2.0