本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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();
}
}
示例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;
}