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


PHP cache_definition::get_mode方法代码示例

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


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

示例1: initialise

 /**
  * Initialises the store instance for a definition.
  * @param cache_definition $definition
  */
 public function initialise(cache_definition $definition)
 {
     // If the definition isn't using static acceleration then we need to be store data here.
     // The reasoning behind this is that:
     //   - If the definition is using static acceleration then the cache loader is going to
     //     store things in its static array.
     //   - If the definition is not using static acceleration then the cache loader won't try to store anything
     //     and we will need to store it here in order to make sure it is accessible.
     if ($definition->get_mode() !== self::MODE_APPLICATION) {
         // Neither the request cache nor the session cache provide static acceleration.
         $this->persist = true;
     } else {
         $this->persist = !$definition->use_static_acceleration();
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:dummystore.php

示例2: create_store_from_config

 /**
  * Creates a store instance given its name and configuration.
  *
  * If the store has already been instantiated then the original objetc will be returned. (reused)
  *
  * @param string $name The name of the store (must be unique remember)
  * @param array $details
  * @param cache_definition $definition The definition to instantiate it for.
  * @return boolean|cache_store
  */
 public function create_store_from_config($name, array $details, cache_definition $definition)
 {
     if (!array_key_exists($name, $this->stores)) {
         // Properties: name, plugin, configuration, class.
         $class = $details['class'];
         $store = new $class($details['name'], $details['configuration']);
         $this->stores[$name] = $store;
     }
     $store = $this->stores[$name];
     if (!$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) {
         return false;
     }
     // We always create a clone of the original store.
     // If we were to clone a store that had already been initialised with a definition then
     // we'd run into a myriad of issues.
     // We use a method of the store to create a clone rather than just creating it ourselves
     // so that if any store out there doesn't handle cloning they can override this method in
     // order to address the issues.
     $store = $this->stores[$name]->create_clone($details);
     $store->initialise($definition);
     $definitionid = $definition->get_id();
     if (!isset($this->definitionstores[$definitionid])) {
         $this->definitionstores[$definitionid] = array();
     }
     $this->definitionstores[$definitionid][] = $store;
     return $store;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:37,代码来源:factory.php

示例3: get_stores_for_definition

 /**
  * Gets all of the stores that are to be used for the given definition.
  *
  * @param cache_definition $definition
  * @return array
  */
 public function get_stores_for_definition(cache_definition $definition)
 {
     // Check if MUC has been disabled.
     $factory = cache_factory::instance();
     if ($factory->stores_disabled()) {
         // Yip its been disabled.
         // To facilitate this we are going to always return an empty array of stores to use.
         // This will force all cache instances to use the cachestore_dummy.
         // MUC will still be used essentially so that code using it will still continue to function but because no cache stores
         // are being used interaction with MUC will be purely based around a static var.
         return array();
     }
     $availablestores = $this->get_stores($definition->get_mode(), $definition->get_requirements_bin());
     $stores = array();
     $id = $definition->get_id();
     // Now get any mappings and give them priority.
     foreach ($this->configdefinitionmappings as $mapping) {
         if ($mapping['definition'] !== $id) {
             continue;
         }
         $storename = $mapping['store'];
         if (!array_key_exists($storename, $availablestores)) {
             continue;
         }
         if (array_key_exists($storename, $stores)) {
             $store = $stores[$storename];
             unset($stores[$storename]);
             $stores[$storename] = $store;
         } else {
             $stores[$storename] = $availablestores[$storename];
         }
     }
     if (empty($stores) && !$definition->is_for_mappings_only()) {
         $mode = $definition->get_mode();
         // Load the default stores.
         foreach ($this->configmodemappings as $mapping) {
             if ($mapping['mode'] === $mode && array_key_exists($mapping['store'], $availablestores)) {
                 $store = $availablestores[$mapping['store']];
                 if (empty($store['mappingsonly'])) {
                     $stores[$mapping['store']] = $store;
                 }
             }
         }
     }
     return $stores;
 }
开发者ID:Burick,项目名称:moodle,代码行数:52,代码来源:config.php

示例4: get_definition_stat_id_and_mode

 /**
  * Returns a string to describe the definition.
  *
  * This method supports the definition as a string due to legacy requirements.
  * It is backwards compatible when a string is passed but is not accurate.
  *
  * @since 2.9
  * @param cache_definition|string $definition
  * @return string
  */
 protected static function get_definition_stat_id_and_mode($definition)
 {
     if (!$definition instanceof cache_definition) {
         // All core calls to this method have been updated, this is the legacy state.
         // We'll use application as the default as that is the most common, really this is not accurate of course but
         // at this point we can only guess and as it only affects calls to cache stat outside of core (of which there should
         // be none) I think that is fine.
         debugging('Please update you cache stat calls to pass the definition rather than just its ID.', DEBUG_DEVELOPER);
         return array((string) $definition, cache_store::MODE_APPLICATION);
     }
     return array($definition->get_id(), $definition->get_mode());
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:22,代码来源:helper.php

示例5: create_store_from_config

 /**
  * Creates a store instance given its name and configuration.
  *
  * If the store has already been instantiated then the original objetc will be returned. (reused)
  *
  * @param string $name The name of the store (must be unique remember)
  * @param array $details
  * @param cache_definition $definition The definition to instantiate it for.
  * @return boolean|cache_store
  */
 public function create_store_from_config($name, array $details, cache_definition $definition)
 {
     if (!array_key_exists($name, $this->stores)) {
         // Properties: name, plugin, configuration, class.
         $class = $details['class'];
         $store = new $class($details['name'], $details['configuration']);
         $this->stores[$name] = $store;
     }
     $store = $this->stores[$name];
     if (!$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) {
         return false;
     }
     $store = clone $this->stores[$name];
     $store->initialise($definition);
     return $store;
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:26,代码来源:factory.php

示例6: initialise

 /**
  * Initialises the cache.
  *
  * Once this has been done the cache is all set to be used.
  *
  * @param cache_definition $definition
  */
 public function initialise(cache_definition $definition)
 {
     $this->definition = $definition;
     $hash = preg_replace('#[^a-zA-Z0-9]+#', '_', $this->definition->get_id());
     $this->path = $this->filestorepath . '/' . $hash;
     make_writable_directory($this->path);
     if ($this->prescan && $definition->get_mode() !== self::MODE_REQUEST) {
         $this->prescan = false;
     }
     if ($this->prescan) {
         $this->prescan_keys();
     }
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:20,代码来源:lib.php

示例7: initialise

 /**
  * Initialises a new instance of the cache store given the definition the instance is to be used for.
  *
  * This function should prepare any given connections etc.
  *
  * @param cache_definition $definition
  * @return bool
  */
 public function initialise(cache_definition $definition)
 {
     $this->definition = $definition;
     $definition_id = $definition->get_mode() . '/' . $definition->get_component() . '/' . $definition->get_area();
     $this->prefix = $this->name . '/data/' . $definition_id . '/';
     $this->prefix_lock = $this->name . '/lock/' . $definition_id . '/';
     $this->prefix_length = strlen($this->prefix);
     return true;
 }
开发者ID:linnaea,项目名称:moodle-cachestore_apcu,代码行数:17,代码来源:lib.php


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