cwbit / cakephp-aggregate-cache

A Behavior plugin for CakePHP that extends the idea of counterCache and counterScope to more fields
8 stars 4 forks source link

The future: clever cache updates? #2

Open Ali1 opened 10 years ago

Ali1 commented 10 years ago

Thanks for repoing and improving this excellent Behaviour. It would be great if it was a bit smarter. Most of the aggregates can be computed beforeSave and beforeDelete just by knowing about the item that has changed and the old aggregate value that has already been calculated previously - saving a potentially heavy database query. Obviously you cannot always compute the new aggregate but in a majority of times it would.

Once this is done, future features could be that it could rely on the actual Cache to store aggregate values rather than in the database. Wow.

Indemnity83 commented 10 years ago

The problem with doing any cache calculation exclusively beforeSave or beforeDelete is what do you do it the save or delete fails?