本文整理汇总了PHP中cache_definition::uses_simple_data方法的典型用法代码示例。如果您正苦于以下问题:PHP cache_definition::uses_simple_data方法的具体用法?PHP cache_definition::uses_simple_data怎么用?PHP cache_definition::uses_simple_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache_definition
的用法示例。
在下文中一共展示了cache_definition::uses_simple_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: static_acceleration_set
/**
* Sets a key value pair into the static acceleration array.
*
* @param string $key The parsed key
* @param mixed $data
* @return bool
*/
protected function static_acceleration_set($key, $data)
{
if ($this->staticaccelerationsize !== false && isset($this->staticaccelerationkeys[$key])) {
$this->staticaccelerationcount--;
unset($this->staticaccelerationkeys[$key]);
}
// We serialize anything that's not;
// 1. A known scalar safe value.
// 2. A definition that says it's simpledata. We trust it that it doesn't contain dangerous references.
// 3. An object that handles dereferencing by itself.
if (is_scalar($data) || $this->definition->uses_simple_data() || $data instanceof cache_cached_object) {
$this->staticaccelerationarray[$key]['data'] = $data;
$this->staticaccelerationarray[$key]['serialized'] = false;
} else {
$this->staticaccelerationarray[$key]['data'] = serialize($data);
$this->staticaccelerationarray[$key]['serialized'] = true;
}
if ($this->staticaccelerationsize !== false) {
$this->staticaccelerationcount++;
$this->staticaccelerationkeys[$key] = $key;
if ($this->staticaccelerationcount > $this->staticaccelerationsize) {
$dropkey = array_shift($this->staticaccelerationkeys);
unset($this->staticaccelerationarray[$dropkey]);
$this->staticaccelerationcount--;
}
}
return true;
}
示例2: unref
/**
* Removes references where required.
*
* @param stdClass|array $data
* @return mixed What ever was put in but without any references.
*/
protected function unref($data)
{
if ($this->definition->uses_simple_data()) {
return $data;
}
// Check if it requires serialisation in order to produce a reference free copy.
if ($this->requires_serialisation($data)) {
// Damn, its going to have to be serialise.
$data = serialize($data);
// We unserialise immediately so that we don't have to do it every time on get.
$data = unserialize($data);
} else {
if (!is_scalar($data)) {
// Its safe to clone, lets do it, its going to beat the pants of serialisation.
$data = $this->deep_clone($data);
}
}
return $data;
}
示例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)
{
$keyarray = $definition->generate_multi_key_parts();
$this->storeid = $keyarray['mode'] . '/' . $keyarray['component'] . '/' . $keyarray['area'] . '/' . $keyarray['siteidentifier'];
$this->store =& self::register_store_id($this->storeid);
$maxsize = $definition->get_maxsize();
$this->simpledata = $definition->uses_simple_data();
if ($maxsize !== null) {
// Must be a positive int.
$this->maxsize = abs((int) $maxsize);
$this->storecount = count($this->store);
}
}