views:

14

answers:

0

Hi,

I'm caching an HABTM relation in CakePHP.
Some children (Showcases) of the root model (Client) get updated once in a while because they get published or unpublished. That means that the Cached query should expire.
But... it doesn't. It only expires when one of the children is added or removed. How do I properly make the update action of a child propagate to its parents and only 'touch' their modified field?

The find statement looks like this:

$clients = null;
if(($clients = Cache::read('clients')) === false){
$this->Client->Behaviors->attach('Containable');
$clients = $this->Client->find('all', array(
                'fields'=>array('Client.id','Client.name','Client.url'),
                'contain' => array(
                    'Showcase'=> array(
                    'conditions'=>array('Showcase.published'=>true),
    'fields'=>array('Showcase.name','Showcase.published','Showcase.question','Showcase.id'),
                            'Galleryitem' => array(
                            'conditions'=>array('Galleryitem.published'=>true),
                            'fields'=>array('Galleryitem.published','Galleryitem.isimage'),
                            'Image' => array(
                                'fields'=>array('Image.filename')
                                )
                            )
                        )
                    )
                )
            );
            Cache::write('clients',$clients);
        }

Kind regards.