Skip to content

Commit

Permalink
Add docs for CounterCacheBehavior::updateCounterCache().
Browse files Browse the repository at this point in the history
Refs cakehp/cakephp#17967
  • Loading branch information
ADmad committed Oct 20, 2024
1 parent c5dc9cb commit 11b29af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions en/appendices/5-2-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Behavior Changes
New Features
============

ORM
---

- ``CounterCacheBehavior::updateCounterCache()`` has been addded. This method
allows you to update the counter cache values for all records of the configured
associations.

Error
-----

Expand Down
16 changes: 16 additions & 0 deletions en/orm/behaviors/counter-cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,19 @@ with the same code as described above.::
]);

Finally clear all caches with ``bin/cake cache clear_all`` and try it out.

Updating all counter caches
===========================

.. php:method:: updateCounterCache(?string $assocName = null, int $limit = 100, ?int $page = null): void
The ``updateCounterCache()`` method allows you to update the counter cache values
for one or all configured associations in batches. This can be useful, for example,
to update the counter cache after importing data directly into the database.

.. versionadded:: 5.2.0

.. note::

This methods won't update the counter cache values for fields which are
configured to use a closure to get the count value.

0 comments on commit 11b29af

Please sign in to comment.