本文整理汇总了PHP中Cake\Cache\Cache::clearGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::clearGroup方法的具体用法?PHP Cache::clearGroup怎么用?PHP Cache::clearGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Cache\Cache
的用法示例。
在下文中一共展示了Cache::clearGroup方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _clearCacheGroup
/**
* Clear cache group.
*
* @return void
*/
protected function _clearCacheGroup()
{
$cacheGroups = $this->config('groups');
foreach ($cacheGroups as $group) {
Cache::clearGroup($group, $this->config('config'));
}
}
示例2: testGroupClear
/**
* 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'));
}
示例3: testGroupClear
/**
* 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'));
}
示例4: testGroupClearNoPrefix
/**
* 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');
}
示例5: home
/**
* 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]]);
}
示例6: export
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'));
}
}
示例7: testGroupClear
/**
* 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'));
}
示例8: clearCache
/**
* Clear blocks cache for all themes and all regions.
*
* @return void
*/
public function clearCache()
{
Cache::clearGroup('views', 'blocks');
}
示例9: clearCache
/**
* Clear menus cache.
*
* @return void
*/
public function clearCache()
{
Cache::clearGroup('views', 'menus');
}
示例10: clearCache
/**
* Clear permissions cache for all users.
*
* @return void
*/
public function clearCache()
{
Cache::clearGroup('acl', 'permissions');
}