本文整理汇总了PHP中Cake\Cache\Cache::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::delete方法的具体用法?PHP Cache::delete怎么用?PHP Cache::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Cache\Cache
的用法示例。
在下文中一共展示了Cache::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNonFatalErrorsWithCacheDisable
/**
* Check that no fatal errors are issued doing normal things when Cache.disable is true.
*
* @return void
*/
public function testNonFatalErrorsWithCacheDisable()
{
Cache::disable();
$this->_configCache();
$this->assertNull(Cache::write('no_save', 'Noooo!', 'tests'));
$this->assertFalse(Cache::read('no_save', 'tests'));
$this->assertNull(Cache::delete('no_save', 'tests'));
}
示例2: testNonFatalErrorsWithCachedisable
/**
* Check that no fatal errors are issued doing normal things when Cache.disable is true.
*
* @return void
*/
public function testNonFatalErrorsWithCachedisable()
{
Cache::disable();
$this->_configCache();
Cache::write('no_save', 'Noooo!', 'tests');
Cache::read('no_save', 'tests');
Cache::delete('no_save', 'tests');
}
示例3: setUp
/**
* setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
TableRegistry::clear();
$this->Articles = TableRegistry::get('Articles');
Cache::config('default', ['className' => 'File', 'path' => CACHE, 'duration' => '+10 days']);
Cache::delete('Related.attachedTables');
Cache::delete('Related.indexedTables');
}
示例4: testDescribeCache
/**
* Tests that schema metadata is cached
*
* @return void
*/
public function testDescribeCache()
{
$schema = $this->connection->schemaCollection();
$table = $this->connection->schemaCollection()->describe('users');
Cache::delete('test_users', '_cake_model_');
$schema->cacheMetadata(true);
$result = $schema->describe('users');
$this->assertEquals($table, $result);
$result = Cache::read('test_users', '_cake_model_');
$this->assertEquals($table, $result);
}
示例5: testDescribeCache
/**
* Tests that schema metadata is cached
*
* @return void
*/
public function testDescribeCache()
{
$schema = $this->connection->methodSchemaCollection();
$method = $this->connection->methodSchemaCollection()->describe('CALC.SUM');
Cache::delete('test_CALC_SUM', '_cake_method_');
$this->connection->cacheMetadata(true);
$schema = $this->connection->methodSchemaCollection();
$result = $schema->describe('CALC.SUM');
$this->assertEquals($method, $result);
$result = Cache::read('test_CALC_SUM', '_cake_method_');
$this->assertEquals($method, $result);
}
示例6: load
/**
* Loads a plugin and optionally loads bootstrapping and routing files.
*
* This method is identical to CakePlugin::load() with extra functionality
* that loads event configuration when Plugin/Config/events.php is present.
*
* @see CakePlugin::load()
* @param mixed $plugin name of plugin, or array of plugin and its config
* @return void
*/
public static function load($plugin, $config = [])
{
Plugin::load($plugin, $config);
if (is_string($plugin)) {
$plugin = [$plugin => $config];
}
Cache::delete('EventHandlers', 'default');
foreach ($plugin as $name => $conf) {
list($name, $conf) = is_numeric($name) ? [$conf, $config] : [$name, $conf];
Hook::applyHookConfigFiles('Hook.config_files', $name);
}
}
示例7: clear
protected function clear($alias, array $params = [])
{
$params += ['config' => true, 'cache' => true];
if (true === $params['config']) {
$key = $this->Items->behaviors()->get($alias)->cacheKey();
Cache::delete($key);
}
if (true === $params['cache']) {
$behavior = $this->Items->behaviors()->get($alias);
$key = ConfigureKey::fqn($behavior);
Configure::write($key, null);
}
}
示例8: testGetTypes
/**
* Tests the getTypes method
*
* @return void
* @covers ::getTypes
*/
public function testGetTypes()
{
Cache::delete('database_log_types');
$this->Logs->deleteAll('1=1');
$data = ['type' => 'Foo', 'message' => 'some text'];
$log = $this->Logs->newEntity($data);
$res = $this->Logs->save($log);
$this->assertTrue(!empty($res));
$data = ['type' => 'Bar', 'message' => 'some more text'];
$log = $this->Logs->newEntity($data);
$res = $this->Logs->save($log);
$this->assertTrue(!empty($res));
$res = $this->Logs->getTypes();
$this->assertSame(['Bar', 'Foo'], $res);
}
示例9: beforeLayout
/**
* Callback for Helper::beforeLayout
*
* @param Event $view Event
* @param string $layoutFile layout file name
*
* @return bool true
*/
public function beforeLayout(Event $event, $layoutFile)
{
if (!Cache::enabled()) {
$this->config('disable', true);
} elseif (!$this->request->is('get')) {
$this->config('disable', true);
} elseif ($this->request->session()->check('Flash')) {
$this->config('disable', true);
} elseif ($this->_View->get(ViewMemcachedHelper::NOCACHE)) {
$this->config('disable', true);
}
if ($this->_View->get(ViewMemcachedHelper::DELETE) === true) {
Cache::delete($this->config('cacheKey'), $this->config('cacheConfig'));
}
return true;
}
示例10: edit
/**
* Edit a setting.
*
* @return \Cake\Network\Response|void
*/
public function edit()
{
$setting = $this->Settings->find()->where(['Settings.id' => $this->request->id])->first();
if (is_null($setting)) {
$this->Flash->error(__d('admin', 'This setting doesn\'t exist or has been deleted.'));
return $this->redirect(['action' => 'index']);
}
if ($this->request->is(['post', 'put'])) {
$this->Settings->patchEntity($setting, $this->request->data);
$setting->last_updated_user_id = $this->Auth->user('id');
if ($this->Settings->save($setting)) {
Cache::delete('settings', 'database');
$this->Flash->success(__d('admin', 'This setting has been edited successfully !'));
return $this->redirect(['action' => 'index']);
}
}
$this->set(compact('setting'));
}
示例11: clear
/**
* Clear metadata.
*
* @param string|null $name The name of the table to clear cache data for.
* @return bool
*/
public function clear($name = null)
{
$schema = $this->_getSchema();
if (!$schema) {
return false;
}
$tables = [$name];
if (empty($name)) {
$tables = $schema->listTables();
}
$configName = $schema->cacheMetadata();
foreach ($tables as $table) {
$this->_io->verbose(sprintf('Clearing metadata cache from "%s" for %s', $configName, $table));
$key = $schema->cacheKey($table);
Cache::delete($key, $configName);
}
$this->out('<success>Cache clear complete</success>');
return true;
}
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$schema = $this->_getSchema($input, $output);
$name = $input->getArgument('name');
if (!$schema) {
return false;
}
$tables = [$name];
if (empty($name)) {
$tables = $schema->listTables();
}
$configName = $schema->cacheMetadata();
foreach ($tables as $table) {
$output->writeln(sprintf('Clearing metadata cache from "%s" for %s', $configName, $table));
$key = $schema->cacheKey($table);
Cache::delete($key, $configName);
}
$output->writeln('<info>Cache clear complete<info>');
return true;
}
示例13: testAdd
/**
* Test add
*
* @return void
*/
public function testAdd()
{
Cache::delete('test_add_key', 'memcached');
$result = Cache::add('test_add_key', 'test data', 'memcached');
$this->assertTrue($result);
$expected = 'test data';
$result = Cache::read('test_add_key', 'memcached');
$this->assertEquals($expected, $result);
$result = Cache::add('test_add_key', 'test data 2', 'memcached');
$this->assertFalse($result);
}
示例14: doDelete
/**
* {@inheritDoc}
*/
protected function doDelete($id)
{
return Cache::delete($id, $this->config);
}
示例15: testViewVarNocache
/**
* testViewVarNocache method
*
* @return void
*/
public function testViewVarNocache()
{
$this->helper->config('gzipCompress', false);
$cacheConfig = $this->helper->config('cacheConfig');
$cacheKey = $this->helper->config('cacheKey');
Cache::delete($cacheKey, $cacheConfig);
$this->View->set(ViewMemcachedHelper::NOCACHE, true);
$this->View->set('test', 'nocache');
$content = $this->View->render('home', 'default');
$cache = Cache::read($cacheKey, $cacheConfig);
$this->assertTrue($cache === false);
}