当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::deleteTags方法代码示例

本文整理汇总了PHP中Drupal\Core\Cache\Cache::deleteTags方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::deleteTags方法的具体用法?PHP Cache::deleteTags怎么用?PHP Cache::deleteTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Cache\Cache的用法示例。


在下文中一共展示了Cache::deleteTags方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testTagDeletetions

 public function testTagDeletetions()
 {
     // Create cache entry in multiple bins.
     $tags = array('test_tag' => array(1, 2, 3));
     $bins = array('data', 'bootstrap', 'render');
     foreach ($bins as $bin) {
         $bin = \Drupal::cache($bin);
         $bin->set('test', 'value', Cache::PERMANENT, $tags);
         $this->assertTrue($bin->get('test'), 'Cache item was set in bin.');
     }
     $deletions_before = intval(db_select('cachetags')->fields('cachetags', array('deletions'))->condition('tag', 'test_tag:2')->execute()->fetchField());
     Cache::deleteTags(array('test_tag' => array(2)));
     // Test that cache entry has been deleted in multiple bins.
     foreach ($bins as $bin) {
         $bin = \Drupal::cache($bin);
         $this->assertFalse($bin->get('test'), 'Tag invalidation affected item in bin.');
     }
     // Test that only one tag deletion has occurred.
     $deletions_after = intval(db_select('cachetags')->fields('cachetags', array('deletions'))->condition('tag', 'test_tag:2')->execute()->fetchField());
     $this->assertEqual($deletions_after, $deletions_before + 1, 'Only one addition cache tag deletion has occurred after deleting a tag used in multiple bins.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:21,代码来源:DatabaseBackendTagTest.php

示例2: onRouterRebuild

 /**
  * Rebuilds the menu links and deletes the local_task cache tag.
  *
  * @param \Symfony\Component\EventDispatcher\Event $event
  *   The event object.
  */
 public function onRouterRebuild(Event $event)
 {
     $this->menuLinksRebuild();
     Cache::deleteTags(array('local_task' => 1));
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:RouterRebuildSubscriber.php

示例3: testDeleteTags

 /**
  * @covers deleteTags
  *
  * @expectedException \LogicException
  * @expectedExceptionMessage Cache tags must be strings, array given.
  */
 public function testDeleteTags()
 {
     Cache::deleteTags(['node' => [2, 3, 5, 8, 13]]);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:10,代码来源:CacheTest.php

示例4: rename

 /**
  * Implements Drupal\Core\Config\StorageInterface::rename().
  */
 public function rename($name, $new_name)
 {
     // If the cache was the first to be deleted, another process might start
     // rebuilding the cache before the storage is renamed.
     if ($this->storage->rename($name, $new_name)) {
         $this->cache->delete($this->getCacheKey($name));
         $this->cache->delete($this->getCacheKey($new_name));
         Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG));
         $this->findByPrefixCache = array();
         return TRUE;
     }
     return FALSE;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:16,代码来源:CachedStorage.php

示例5: clearCachedBundles

 /**
  * {@inheritdoc}
  */
 public function clearCachedBundles()
 {
     $this->bundleInfo = array();
     Cache::deleteTags(array('entity_bundles' => TRUE));
     // Entity bundles are exposed as data types, clear that cache too.
     $this->typedDataManager->clearCachedDefinitions();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:EntityManager.php

示例6: resetSystem

 /**
  * Resets some other systems like rebuilding the route information or caches.
  */
 protected function resetSystem()
 {
     if ($this->routeBuilder) {
         $this->routeBuilder->setRebuildNeeded();
     }
     $this->systemListReset();
     // @todo It feels wrong to have the requirement to clear the local tasks
     //   cache here.
     Cache::deleteTags(array('local_task' => 1));
     $this->themeRegistryRebuild();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:14,代码来源:ThemeHandler.php

示例7: testCacheClearByCacheTag

 /**
  * Tests that all toolbar cache entries for a user are cleared with a cache
  * tag for that user, i.e. cache entries for all languages for that user.
  */
 function testCacheClearByCacheTag()
 {
     // Test that the toolbar admin menu subtrees cache is invalidated for a user
     // across multiple languages.
     $this->drupalLogin($this->admin_user);
     $toolbarCache = $this->container->get('cache.toolbar');
     $admin_user_id = $this->admin_user->id();
     $admin_user_2_id = $this->admin_user_2->id();
     // Assert that a cache tag in the toolbar cache under the key "user" exists
     // for admin_user against the language "en".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . 'en');
     $this->assertEqual($cache->tags[0], 'user:' . $admin_user_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user against the language "en".');
     // Assert that no toolbar cache exists for admin_user against the
     // language "fr".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . 'fr');
     $this->assertFalse($cache, 'No toolbar cache exists for admin_user against the language "fr".');
     // Install a second language.
     $edit = array('predefined_langcode' => 'fr');
     $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
     // Request a page in 'fr' to update the cache.
     $this->drupalGet('fr/test-page');
     $this->assertResponse(200);
     // Assert that a cache tag in the toolbar cache under the key "user" exists
     // for admin_user against the language "fr".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . 'fr');
     $this->assertEqual($cache->tags[0], 'user:' . $admin_user_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user against the language "fr".');
     // Log in the admin_user_2 user. We will use this user as a control to
     // verify that clearing a cache tag for admin_user does not clear the cache
     // for admin_user_2.
     $this->drupalLogin($this->admin_user_2);
     // Request a page in 'en' to create the cache.
     $this->drupalGet('test-page');
     $this->assertResponse(200);
     // Assert that a cache tag in the toolbar cache under the key "user" exists
     // for admin_user_2 against the language "en".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'en');
     $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "en".');
     // Request a page in 'fr' to create the cache.
     $this->drupalGet('fr/test-page');
     $this->assertResponse(200);
     // Assert that a cache tag in the toolbar cache under the key "user" exists
     // for admin_user against the language "fr".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'fr');
     $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "fr".');
     // Log in admin_user and clear the caches for this user using a tag.
     $this->drupalLogin($this->admin_user);
     Cache::deleteTags(array('user' => array($admin_user_id)));
     // Assert that no toolbar cache exists for admin_user against the
     // language "en".
     $cache = $toolbarCache->get($admin_user_id . ':' . 'en');
     $this->assertFalse($cache, 'No toolbar cache exists for admin_user against the language "en".');
     // Assert that no toolbar cache exists for admin_user against the
     // language "fr".
     $cache = $toolbarCache->get($admin_user_id . ':' . 'fr');
     $this->assertFalse($cache, 'No toolbar cache exists for admin_user against the language "fr".');
     // Log in admin_user_2 and verify that this user's caches still exist.
     $this->drupalLogin($this->admin_user_2);
     // Assert that a cache tag in the toolbar cache under the key "user" exists
     // for admin_user_2 against the language "en".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'en');
     $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "en".');
     // Assert that a cache tag in the toolbar cache under the key "user" exists
     // for admin_user_2 against the language "fr".
     $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'fr');
     $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "fr".');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:70,代码来源:ToolbarAdminMenuTest.php

示例8: clearCachedDefinitions

 /**
  * {@inheritdoc}
  */
 public function clearCachedDefinitions()
 {
     if ($this->cacheBackend) {
         if ($this->cacheTags) {
             // Use the cache tags to clear the cache.
             Cache::deleteTags($this->cacheTags);
         } else {
             $this->cacheBackend->delete($this->cacheKey);
         }
     }
     $this->definitions = NULL;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:15,代码来源:DefaultPluginManager.php

示例9: clear

 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     $this->reset();
     if ($this->tags) {
         Cache::deleteTags($this->tags);
     } else {
         $this->cache->delete($this->getCid());
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:12,代码来源:CacheCollector.php

示例10: clear

 /**
  * Clears the class storage and cache.
  */
 public function clear()
 {
     $this->storage = array();
     $this->allStorage = array();
     $this->fullyLoaded = FALSE;
     Cache::deleteTags(array('views_data' => TRUE));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:ViewsData.php


注:本文中的Drupal\Core\Cache\Cache::deleteTags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。