本文整理汇总了PHP中Cake\Cache\Cache::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::clear方法的具体用法?PHP Cache::clear怎么用?PHP Cache::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Cache\Cache
的用法示例。
在下文中一共展示了Cache::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
Cache::clear(false, 'session_test');
Cache::drop('session_test');
unset($this->storage);
}
示例2: setUp
/**
* Setup function
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->connection = ConnectionManager::get('test');
Cache::clear(false, '_cake_method_');
Cache::enable();
}
示例3: testTranslationCaching
/**
* testTranslationCaching method
*
* @return void
*/
public function testTranslationCaching()
{
$this->skipIf(!Cache::engine('_cake_core_'), 'Missing _cake_core_ cache config, cannot test caching.');
Configure::write('Config.language', 'cache_test_po');
// reset internally stored entries
I18n::clear();
Cache::clear(false, '_cake_core_');
$lang = Configure::read('Config.language');
// make some calls to translate using different domains
$this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
$this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
$domains = I18n::domains();
$this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
// reset internally stored entries
I18n::clear();
// now only dom1 should be in cache
$cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
$this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
$this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
// dom2 not in cache
$this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
// translate a item of dom2 (adds dom2 to cache)
$this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
// verify dom2 was cached through manual read from cache
$cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
$this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
$this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
// modify cache entry manually to verify that dom1 entries now will be read from cache
$cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
$this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
}
示例4: main
/**
* Execute the ClearCache task.
*
* @return void
*/
public function main()
{
Cache::clear(false, '_cake_core_');
Cache::clear(false, 'database');
Cache::clear(false, 'acl');
$this->out('<info>The</info> "<error>deployer clear_cache</error>" <info>command has been executed successfully !</info>', 2);
}
示例5: setUp
/**
* Setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
Cache::clear(false);
$this->apiFolderName = 'NonExistingApiPrefixedFolder';
$this->apiFolderPath = APP . 'Controller' . DS . $this->apiFolderName;
}
示例6: cleanup
/**
* Clears the cache
*
* @return void
*/
public function cleanup()
{
Cache::clear(false, 'default');
Cache::clear(false, '_cake_model_');
Cache::clear(false, '_cake_core_');
$this->dispatchShell('orm_cache clear');
$this->dispatchShell('orm_cache build');
}
示例7: main
public function main()
{
if (Cache::clear(false)) {
$this->success('Cake cache clear complete');
} else {
$this->err("Error : Cake cache clear failed");
}
}
示例8: tearDown
/**
* Tear down method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
I18n::clear();
I18n::defaultFormatter('default');
I18n::locale($this->locale);
Plugin::unload();
Cache::clear(false, '_cake_core_');
}
示例9: clearCache
/**
* Clear a named cache.
*
* @return void
* @throws \Cake\Network\Exception\NotFoundException
*/
public function clearCache()
{
$this->request->allowMethod('post');
if (!$this->request->data('name')) {
throw new NotFoundException('Invalid cache engine name.');
}
$result = Cache::clear(false, $this->request->data('name'));
$this->set(['_serialize' => ['success'], 'success' => $result]);
}
示例10: index
public function index()
{
//Just a way to trigger committed migrations from web interface
echo "<pre>";
passthru('php ../bin/cake.php migrations migrate -vvv');
echo "</pre>";
//Clear the Model cache so any db updates will re-load
\Cake\Cache\Cache::clear(false, '_cake_model_');
exit;
}
示例11: down
/**
* Migrate down
*/
public function down()
{
$table = $this->table('menus');
$table->addColumn('name', 'string', ['limit' => 255, 'null' => false])->addColumn('menu_item_count', 'integer', ['default' => 0, 'null' => false])->addColumn('created', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])->addColumn('modified', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']);
$table->addIndex('name', ['name' => 'BY_NAME', 'unique' => false]);
$table->create();
$id = new Column();
$id->setIdentity(true)->setType('integer')->setOptions(['limit' => 11, 'signed' => false, 'null' => false]);
$table->changeColumn('id', $id)->save();
Cache::clear();
}
示例12: testPermissionLevelAndAjax
/**
* Test permission with setup level and ajax request.
*
* @return void
*/
public function testPermissionLevelAndAjax()
{
$url = array_replace($this->url, ['action' => 'permissions', 2, 0]);
$this->_request['environment']['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
Cache::clear('permissions_aco_2', 'permissions');
$this->get($url);
$viewVars = $this->_controller->viewVars;
$this->assertResponseOk();
$this->assertInstanceOf('JBZoo\\Data\\Data', $viewVars['permissions'][3]);
$this->assertSame('display', $viewVars['permissions'][3]->get('alias'));
$this->assertSame(1, count($viewVars['acos']));
}
示例13: setUp
public function setUp()
{
parent::setUp();
if ($this->isDebug()) {
$this->GeoImport = new GeoImportLib();
return;
}
$this->GeoImport = $this->getMock('Data\\Lib\\GeoImportLib', ['_getFromUrl']);
$this->path = Plugin::path('Data') . 'tests' . DS . 'test_files' . DS . 'html' . DS;
// Liste-der-St-C3-A4dte-in-der-Schweiz-action-edit-section-4.html
Cache::clear();
}
示例14: down
/**
* Migrate down
*/
public function down()
{
$table = $this->table('menu_items');
$table->addColumn('menu_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])->addColumn('parent_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => true, 'default' => null])->addColumn('lft', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])->addColumn('rght', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])->addColumn('name', 'string', ['limit' => 255, 'null' => false])->addColumn('type', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('target', 'text', ['null' => true, 'default' => null])->addColumn('external_link', 'text', ['null' => true, 'default' => null])->addColumn('foreign_model', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('foreign_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => true, 'default' => null])->addColumn('plugin', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('controller', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('action', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('params', 'text', ['null' => true, 'default' => null])->addColumn('query', 'text', ['null' => true, 'default' => null])->addColumn('created', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])->addColumn('modified', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']);
$table->addIndex('menu_id', ['name' => 'FK_MENU_ID', 'unique' => false]);
$table->addIndex('parent_id', ['name' => 'FK_PARENT_ID', 'unique' => false]);
$table->create();
$id = new Column();
$id->setIdentity(true)->setType('integer')->setOptions(['limit' => 11, 'signed' => false, 'null' => false]);
$table->changeColumn('id', $id)->save();
Cache::clear();
}
示例15: find
/**
* Creates a new Query for this repository and applies some defaults based
* on the type of search that was selected
* @param string $type The type of query to perform
* @param array|ArrayAccess $options An array that will be passed to
* Query::applyOptions()
* @return Cake\ORM\Query The query builder
* @uses setNextToBePublished()
* @uses $cache
*/
public function find($type = 'all', $options = [])
{
//Gets from cache the timestamp of the next record to be published
$next = Cache::read('next_to_be_published', $this->cache);
//If the cache is not valid, it empties the cache
if ($next && time() >= $next) {
Cache::clear(false, $this->cache);
//Sets the next record to be published
$this->setNextToBePublished();
}
return parent::find($type, $options);
}