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


PHP cache_definition::get_id方法代码示例

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


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

示例1: get_from_persist_cache

 /**
  * Returns the item from the static acceleration array if it exists there.
  *
  * @param string $key The parsed key
  * @return mixed|false The data from the static acceleration array or false if it wasn't there.
  */
 protected function get_from_persist_cache($key)
 {
     // This method of checking if an array was supplied is faster than is_array.
     if ($key === (array) $key) {
         $key = $key['key'];
     }
     // This isset check is faster than array_key_exists but will return false
     // for null values, meaning null values will come from backing store not
     // the static acceleration array. We think this okay because null usage should be
     // very rare (see comment in MDL-39472).
     if (!$this->staticacceleration || !isset($this->staticaccelerationarray[$key])) {
         $result = false;
     } else {
         $data = $this->staticaccelerationarray[$key];
         if (!$this->has_a_ttl() || !$data instanceof cache_ttl_wrapper) {
             if ($data instanceof cache_cached_object) {
                 $data = $data->restore_object();
             }
             $result = $data;
         } else {
             if ($data->has_expired()) {
                 $this->delete_from_persist_cache($key);
                 $result = false;
             } else {
                 if ($data instanceof cache_cached_object) {
                     $data = $data->restore_object();
                 }
                 $result = $data->data;
             }
         }
     }
     if ($result) {
         if ($this->perfdebug) {
             cache_helper::record_cache_hit('** static acceleration **', $this->definition->get_id());
         }
         if ($this->staticaccelerationsize > 1 && $this->staticaccelerationcount > 1) {
             // Check to see if this is the last item on the static acceleration keys array.
             if (end($this->staticaccelerationkeys) !== $key) {
                 // It isn't the last item.
                 // Move the item to the end of the array so that it is last to be removed.
                 unset($this->staticaccelerationkeys[$key]);
                 $this->staticaccelerationkeys[$key] = $key;
             }
         }
         return $result;
     } else {
         if ($this->perfdebug) {
             cache_helper::record_cache_miss('** static acceleration **', $this->definition->get_id());
         }
         return false;
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:58,代码来源:loaders.php

示例2: get_from_persist_cache

 /**
  * Returns the item from the persist cache if it exists there.
  *
  * @param string $key The parsed key
  * @return mixed|false The data from the persist cache or false if it wasn't there.
  */
 protected function get_from_persist_cache($key)
 {
     if (is_array($key)) {
         $key = $key['key'];
     }
     if (!$this->persist || !array_key_exists($key, $this->persistcache)) {
         $result = false;
     } else {
         $data = $this->persistcache[$key];
         if (!$this->has_a_ttl() || !$data instanceof cache_ttl_wrapper) {
             if ($data instanceof cache_cached_object) {
                 $data = $data->restore_object();
             }
             $result = $data;
         } else {
             if ($data->has_expired()) {
                 $this->delete_from_persist_cache($key);
                 $result = false;
             } else {
                 if ($data instanceof cache_cached_object) {
                     $data = $data->restore_object();
                 }
                 $result = $data->data;
             }
         }
     }
     if ($result) {
         if ($this->perfdebug) {
             cache_helper::record_cache_hit('** static persist **', $this->definition->get_id());
         }
         return $result;
     } else {
         if ($this->perfdebug) {
             cache_helper::record_cache_miss('** static persist **', $this->definition->get_id());
         }
         return false;
     }
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:44,代码来源:loaders.php

示例3: 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->storeid = $definition->generate_definition_hash();
     $this->store =& self::register_store_id($this->name . '-' . $definition->get_id());
     $this->ttl = $definition->get_ttl();
     $maxsize = $definition->get_maxsize();
     if ($maxsize !== null) {
         // Must be a positive int.
         $this->maxsize = abs((int) $maxsize);
         $this->storecount = count($this->store);
     }
     $this->check_ttl();
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:20,代码来源:lib.php

示例4: hash_key

 /**
  * Hashes a descriptive key to make it shorter and still unique.
  * @param string|int $key
  * @param cache_definition $definition
  * @return string
  */
 public static function hash_key($key, cache_definition $definition)
 {
     if ($definition->uses_simple_keys()) {
         if (debugging() && preg_match('#[^a-zA-Z0-9_]#', $key)) {
             throw new coding_exception('Cache definition ' . $definition->get_id() . ' requires simple keys. Invalid key provided.', $key);
         }
         // We put the key first so that we can be sure the start of the key changes.
         return (string) $key . '-' . $definition->generate_single_key_prefix();
     }
     $key = $definition->generate_single_key_prefix() . '-' . $key;
     return sha1($key);
 }
开发者ID:Burick,项目名称:moodle,代码行数:18,代码来源:helper.php

示例5: get_store_instances_in_use

 /**
  * Returns an array of cache stores that have been initialised for use in definitions.
  * @param cache_definition $definition
  * @return array
  */
 public function get_store_instances_in_use(cache_definition $definition)
 {
     $id = $definition->get_id();
     if (!isset($this->definitionstores[$id])) {
         return array();
     }
     return $this->definitionstores[$id];
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:13,代码来源:factory.php

示例6: 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

示例7: 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

示例8: 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->storeid = $definition->generate_definition_hash();
     $this->store =& self::register_store_id($definition->get_id());
     $this->ttl = $definition->get_ttl();
 }
开发者ID:Burick,项目名称:moodle,代码行数:13,代码来源:lib.php


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