I am using cakephp2. I have two questions
-
I want to store different cache counts in a separate table. For ex:- user may creates groups, forums etc and I want to store the count instead of querying each time. So I used the counterCache feature of cakephp. Is it possible to store all these counts in a separate table and when the user creates groups/forums etc should update the respective count in that table ?
-
I need to update counterCache count for the groups in such a way that count should be incremented automatically when the user creates a group as well as the user joins in any group. Is it possible in cakephp ?
No, counterCache() was not thought to work with more complex requirements like yours, it is, as any feature in the framework, thought to cover the most common cases. Yours is not an everyday request. 😉
Use the afterSave() callback in the model and add your customized logic there and save the counts to the associated models as you need. But overall I don’t see a reason to add a single table just to store the counts? I don’t see any benefit in this architecture.