Oh, nice. My original reply was deleted.
Anyhoo, I might suggest that you only clear the cache for the particular
Form(s) that were deleted or saved, using Cache::delete('getFormsById' .
$id). Although you may need to double check the event of multiple Forms
being saved or deleted. I think afterSave() and afterDelete() gets called
for each entry, but you may want to check, just in case.
Regards
Reuben Helms
On Friday, 2 August 2013 01:48:26 UTC+10, Eric Haskins wrote:
>
> Here is one of my models for dynamic forms. I hope it helps this is
> CakePHP 2.x so I clear cache afterSave (editing a forms structure) or
> afterDelete (selfexplanatory)
>
> class Forms extends AppModel {
> public $primaryKey = 'id';
>
> public function afterSave($created) {
> parent::afterSave($created);
> Cache::clear();
> clearCache();
> }
>
> public function afterDelete() {
> parent::afterDelete();
> Cache::clear();
> clearCache();
> }
>
> public function getFormsById($id){
> if (($form = Cache::read('getFormsById'.$id)) === false) {
> $form = $this->find('first', array('conditions' =>
> array('Forms.id'=>$id,'Forms.site_id'=>
> Configure::read('Settings.site_id'))));
> Cache::write('getFormsById'.$id, $form);
> }
> return $form;
> }
> }
>
> Hope this helps. I am new to Cake cache so if I am wrong someone please
> feel free to point it out
>
> Eric Haskins
> High Octane Brands LLC
> "Building Brands Not Just Business"
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.