Skip to content

Commit

Permalink
Merge pull request #7942 from cakephp/countercache-command
Browse files Browse the repository at this point in the history
Countercache command
  • Loading branch information
markstory authored Oct 28, 2024
2 parents 4280527 + 58658c5 commit c9d2a6e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
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

0 comments on commit c9d2a6e

Please sign in to comment.