當前位置: 首頁>>代碼示例>>PHP>>正文


PHP cache_helper::purge_stores_used_by_definition方法代碼示例

本文整理匯總了PHP中cache_helper::purge_stores_used_by_definition方法的典型用法代碼示例。如果您正苦於以下問題:PHP cache_helper::purge_stores_used_by_definition方法的具體用法?PHP cache_helper::purge_stores_used_by_definition怎麽用?PHP cache_helper::purge_stores_used_by_definition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cache_helper的用法示例。


在下文中一共展示了cache_helper::purge_stores_used_by_definition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

             $mappings = array(cache_store::MODE_APPLICATION => array($data->{'mode_' . cache_store::MODE_APPLICATION}), cache_store::MODE_SESSION => array($data->{'mode_' . cache_store::MODE_SESSION}), cache_store::MODE_REQUEST => array($data->{'mode_' . cache_store::MODE_REQUEST}));
             $writer = cache_config_writer::instance();
             $writer->set_mode_mappings($mappings);
             redirect($PAGE->url);
         }
     }
     break;
 case 'purgedefinition':
     // Purge a specific definition.
     $definition = required_param('definition', PARAM_SAFEPATH);
     list($component, $area) = explode('/', $definition, 2);
     $factory = cache_factory::instance();
     $definition = $factory->create_definition($component, $area);
     if ($definition->has_required_identifiers()) {
         // We will have to purge the stores used by this definition.
         cache_helper::purge_stores_used_by_definition($component, $area);
     } else {
         // Alrighty we can purge just the data belonging to this definition.
         cache_helper::purge_by_definition($component, $area);
     }
     redirect($PAGE->url, get_string('purgedefinitionsuccess', 'cache'), 5);
     break;
 case 'purgestore':
 case 'purge':
     // Purge a store cache.
     $store = required_param('store', PARAM_TEXT);
     cache_helper::purge_store($store);
     redirect($PAGE->url, get_string('purgestoresuccess', 'cache'), 5);
     break;
 case 'newlockinstance':
     // Adds a new lock instance.
開發者ID:Jtgadbois,項目名稱:Pedadida,代碼行數:31,代碼來源:admin.php

示例2: test_purge_routines

 /**
  * Test purge routines.
  */
 public function test_purge_routines()
 {
     $instance = cache_config_testing::instance(true);
     $instance->phpunit_add_definition('phpunit/purge1', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'purge1'));
     $instance->phpunit_add_definition('phpunit/purge2', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'purge2', 'requireidentifiers' => array('id')));
     $factory = cache_factory::instance();
     $definition = $factory->create_definition('phpunit', 'purge1');
     $this->assertFalse($definition->has_required_identifiers());
     $cache = $factory->create_cache($definition);
     $this->assertInstanceOf('cache_application', $cache);
     $this->assertTrue($cache->set('test', 'test'));
     $this->assertTrue($cache->has('test'));
     cache_helper::purge_by_definition('phpunit', 'purge1');
     $this->assertFalse($cache->has('test'));
     $factory = cache_factory::instance();
     $definition = $factory->create_definition('phpunit', 'purge2');
     $this->assertTrue($definition->has_required_identifiers());
     $cache = $factory->create_cache($definition);
     $this->assertInstanceOf('cache_application', $cache);
     $this->assertTrue($cache->set('test', 'test'));
     $this->assertTrue($cache->has('test'));
     cache_helper::purge_stores_used_by_definition('phpunit', 'purge2');
     $this->assertFalse($cache->has('test'));
     try {
         cache_helper::purge_by_definition('phpunit', 'purge2');
         $this->fail('Should not be able to purge a definition required identifiers without providing them.');
     } catch (coding_exception $ex) {
         $this->assertContains('Identifier required for cache has not been provided', $ex->getMessage());
     }
 }
開發者ID:barrysspace,項目名稱:moodle,代碼行數:33,代碼來源:cache_test.php


注:本文中的cache_helper::purge_stores_used_by_definition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。