CopyPastor

Detecting plagiarism made easy.

Score: 0.8103646745290811; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2021-09-25
by S H A S H A N K

Original Post

Original - Posted on 2012-04-04
by AKKAweb



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I believe CakePHP clears cache in the following manner:
1. If there is an element ie. `articles_most_viewed.ctp` and it is called from within `articles index.ctp` file, then Cake will clear that respective element during an add, edit, delete action. 2. However, if there is an element ie. `frontpage_lastest_articles.ctp` and it is only called in `pages/display.ctp` file (frontpage), then CakePHP will not clear that element since it is not being called from within the `affected/changed model/view`, in this case articles `model/controller/view`.
I havent figure out how to better approach this issue, if there is a better way. However, my quick fix is to call clearCache() in my `admin_add.ctp`, `admin_edit.ctp` and `admin_delete.ctp` files as such:

... function admin_add(){ ... if (!empty($this->data)) { if ($this->Article->save($this->data)) { clearCache(); $this->Session->setFlash('Your post has been saved.'); $this->redirect(array('action' => 'index')); } } }

There might be a better way to handle this. Use this if it fits to you.
I believe CakePHP clears cache in the following manner:
1. If there is an element ie. `articles_most_viewed.ctp` and it is called from within `articles index.ctp` file, then Cake will clear that respective element during an add, edit, delete action. 2. However, if there is an element ie. `frontpage_lastest_articles.ctp` and it is only called in `pages/display.ctp` file (frontpage), then CakePHP will not clear that element since it is not being called from within the affected/changed model/view, in this case `articles` model/controller/view.
I havent figure out how to better approach this issue, if there is a better way. However, my quick fix is to call `clearCache()` in my `admin_add.ctp`, `admin_edit.ctp` and `admin_delete.ctp` files as such:
... function admin_add(){ ... if (!empty($this->data)) { if ($this->Article->save($this->data)) { // I call the following function to clear my entire Cache directory // after this action is successfully processed // =========================================== clearCache(); // =========================================== $this->Session->setFlash('Your post has been saved.'); $this->redirect(array('action' => 'index')); } } }
There might be a better way to handle this, but this is my solution for now. I would be glad to know if there is a better/automagic solution.

        
Present in both answers; Present only in the new answer; Present only in the old answer;