php - CakePHP Cache::clear does not work -


i have cache configuration in bootstrap.php file as

cache::config('long', array(         'engine'     => 'file',         'duration'   => '+1 week',         'probability'=> 100,         'mask'       => 0666,         'path'       => cache . 'long' . ds,     )); 

and trying clear cache when setting edited. below admin_edit function

public function admin_edit($id = null) {         if (!$this->setting->exists($id)) {             throw new notfoundexception(__('invalid setting'));         }         if ($this->request->is('post') || $this->request->is('put')) {             if ($this->setting->save($this->request->data)) {                 $this->session->setflash(__('the setting has been saved'));                 $this->redirect(array('action'=> 'index'));                 cache::clear(false,'long');                 cache::gc();             }else {                 $this->session->setflash(__('the setting not saved. please, try again.'));             }         }else {             $options = array('conditions' => array('setting.' . $this->setting->primarykey=> $id));             $this->request->data = $this->setting->find('first', $options);         }     } 

however, cache::clear(false,'long') not work , not clear cache. not sure going wrong. stuck few days now!

please use below function in controller , run function want clear cache.

    /**      * function clear cache data      * default accessible admin      *      * @access public      * @return void      */     public function clear_cache() {         cache::clear();         clearcache();          $files = array();         $files = array_merge($files, glob(cache . '*')); // remove cached css         $files = array_merge($files, glob(cache . 'css' . ds . '*')); // remove cached css         $files = array_merge($files, glob(cache . 'js' . ds . '*'));  // remove cached js                    $files = array_merge($files, glob(cache . 'models' . ds . '*'));  // remove cached models                    $files = array_merge($files, glob(cache . 'persistent' . ds . '*'));  // remove cached persistent                     foreach ($files $f) {             if (is_file($f)) {                 unlink($f);             }         }          if(function_exists('apc_clear_cache')):               apc_clear_cache();         apc_clear_cache('user');         endif;          $this->set(compact('files'));         $this->layout = 'ajax';     } 

once let me know if not working :)

thanks


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -