Beispiel #1
0
 /**
  * Clear cache group.
  *
  * @return void
  */
 protected function _clearCacheGroup()
 {
     $cacheGroups = $this->config('groups');
     foreach ($cacheGroups as $group) {
         Cache::clearGroup($group, $this->config('config'));
     }
 }
 /**
  * Test clearing a cache group
  *
  * @return void
  */
 public function testGroupClear()
 {
     Cache::config('memcached_groups', ['engine' => 'Memcached', 'duration' => 3600, 'groups' => ['group_a', 'group_b']]);
     $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups'));
     $this->assertTrue(Cache::clearGroup('group_a', 'memcached_groups'));
     $this->assertFalse(Cache::read('test_groups', 'memcached_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value2', 'memcached_groups'));
     $this->assertTrue(Cache::clearGroup('group_b', 'memcached_groups'));
     $this->assertFalse(Cache::read('test_groups', 'memcached_groups'));
 }
Beispiel #3
0
 /**
  * Test clearing a cache group
  *
  * @return void
  */
 public function testGroupClear()
 {
     Cache::config('apc_groups', array('engine' => 'Apc', 'duration' => 0, 'groups' => array('group_a', 'group_b'), 'prefix' => 'test_'));
     $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups'));
     $this->assertTrue(Cache::clearGroup('group_a', 'apc_groups'));
     $this->assertFalse(Cache::read('test_groups', 'apc_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value2', 'apc_groups'));
     $this->assertTrue(Cache::clearGroup('group_b', 'apc_groups'));
     $this->assertFalse(Cache::read('test_groups', 'apc_groups'));
 }
 /**
  * Test that clearGroup works with no prefix.
  *
  * @return void
  */
 public function testGroupClearNoPrefix()
 {
     Cache::config('file_groups', ['className' => 'File', 'duration' => 3600, 'prefix' => '', 'groups' => ['group_a', 'group_b']]);
     Cache::write('key_1', 'value', 'file_groups');
     Cache::write('key_2', 'value', 'file_groups');
     Cache::clearGroup('group_a', 'file_groups');
     $this->assertFalse(Cache::read('key_1', 'file_groups'), 'Did not delete');
     $this->assertFalse(Cache::read('key_2', 'file_groups'), 'Did not delete');
 }
Beispiel #5
0
 /**
  * Toggle home link.
  *
  * @param null $id
  * @return \Cake\Network\Response|void
  */
 public function home($id = null)
 {
     $link = $this->Links->get($id);
     $this->Links->updateAll(['home' => UN_PUBLISH_STATUS], ['home' => PUBLISH_STATUS]);
     $link->status = PUBLISH_STATUS;
     $link->home = PUBLISH_STATUS;
     $cacheKey = $cacheGroup = 'home_link';
     if ($result = $this->Links->save($link)) {
         Cache::clearGroup($cacheKey, $cacheGroup);
         Cache::write($cacheKey, $result, $cacheGroup);
         $this->Flash->success(__d('menus', 'The link «{0}» has bee set how home.', sprintf('<strong>%s</strong>', $link->title)));
     } else {
         $this->Flash->error(__d('menus', 'An error has occurred. Please, try again.'));
     }
     return $this->redirect(['action' => 'index', '?' => ['menu_id' => $link->menu_id]]);
 }
 public function export()
 {
     if ($this->request->is('post')) {
         $listLang = [];
         foreach (Configure::read('Core.System.language') as $key => $item) {
             $listLang = array_merge($listLang, [$key => $item['key']]);
         }
         $lang = $this->request->data['language'];
         $list = $this->Languages->find();
         $content = "";
         $path = APP . "Locale/{$listLang[$lang]}/default.po";
         foreach ($list as $item) {
             $content .= 'msgid "' . $item->key . '"' . "\n" . 'msgstr "' . $item->{$lang} . '"' . "\n";
         }
         if ($File = new File($path, true, 0777)) {
             $File->write($content);
             Cache::clearGroup('persistent');
             $this->Flash->success(__('language exported', true));
         } else {
             $this->Flash->error(__('language can not be exported', true));
         }
         $this->redirect(array('action' => 'index'));
     }
 }
 /**
  * Test clearing a cache group
  *
  * @return void
  */
 public function testGroupClear()
 {
     Cache::config('wincache_groups', ['engine' => 'Wincache', 'duration' => 0, 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_']);
     $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups'));
     $this->assertTrue(Cache::clearGroup('group_a', 'wincache_groups'));
     $this->assertFalse(Cache::read('test_groups', 'wincache_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value2', 'wincache_groups'));
     $this->assertTrue(Cache::clearGroup('group_b', 'wincache_groups'));
     $this->assertFalse(Cache::read('test_groups', 'wincache_groups'));
 }
 /**
  * Clear blocks cache for all themes and all regions.
  *
  * @return void
  */
 public function clearCache()
 {
     Cache::clearGroup('views', 'blocks');
 }
 /**
  * Clear menus cache.
  *
  * @return void
  */
 public function clearCache()
 {
     Cache::clearGroup('views', 'menus');
 }
 /**
  * Clear permissions cache for all users.
  *
  * @return void
  */
 public function clearCache()
 {
     Cache::clearGroup('acl', 'permissions');
 }