CounterCacheBehavior (class)
Class CounterCacheBehavior
CounterCache behavior
Enables models to cache the amount of connections in a given relation.
Examples with Post model belonging to User model
Regular counter cache
[ 'Users' => [ 'post_count' ] ]
Counter cache with scope
[ 'Users' => [ 'posts_published' => [ 'conditions' => [ 'published' => true ] ] ] ]
Counter cache using custom find
[ 'Users' => [ 'posts_published' => [ 'finder' => 'published' // Will be using findPublished() ] ] ]
Counter cache using lambda function returning the count This is equivalent to example #2
[ 'Users' => [ 'posts_published' => function (Event $event, EntityInterface $entity, Table $tabl