$definitions = array(
'string' => array( // Required, unique to the component
'mode' => cache_store::MODE_APPLICATION, // Required
+ 'simpledata' => false, // Optional
'requireidentifiers' => array( // Optional
'lang'
),
* mode - Application, session or request.
The following optional settings can also be defined:
+* simpledata - Set to true if you know that you will only be storing scalar values or arrays of scalar values. Avoids costly investigation of data types.
* requireidentifiers - Any identifiers the definition requires. Must be provided when creating the loader.
* requiredataguarantee - If set to true then only stores that support data guarantee will be used.
* requiremultipleidentifiers - If set to true then only stores that support multiple identifiers will be used.
* [int] Sets the mode for the definition. Must be one of cache_store::MODE_*
*
* Optional settings:
+ * + simpledata
+ * [bool] If set to true we know that the data is scalar or array of scalar.
* + requireidentifiers
* [array] An array of identifiers that must be provided to the cache when it is created.
* + requiredataguarantee
*/
protected $area;
+ /**
+ * Set to true if we know the data is scalar or array of scalar.
+ * @var bool
+ */
+ protected $simpledata = false;
+
/**
* An array of identifiers that must be provided when the definition is used to create a cache.
* @var array
$area = (string)$definition['area'];
// Set the defaults.
+ $simpledata = false;
$requireidentifiers = array();
$requiredataguarantee = false;
$requiremultipleidentifiers = false;
$mappingsonly = false;
$invalidationevents = array();
+ if (array_key_exists('simpledata', $definition)) {
+ $simpledata = (bool)$definition['simpledata'];
+ }
if (array_key_exists('requireidentifiers', $definition)) {
$requireidentifiers = (array)$definition['requireidentifiers'];
}
$cachedefinition->mode = $mode;
$cachedefinition->component = $component;
$cachedefinition->area = $area;
+ $cachedefinition->simpledata = $simpledata;
$cachedefinition->requireidentifiers = $requireidentifiers;
$cachedefinition->requiredataguarantee = $requiredataguarantee;
$cachedefinition->requiremultipleidentifiers = $requiremultipleidentifiers;
return $this->mappingsonly;
}
+ /**
+ * Returns true if the data is known to be scalar or array of scalar.
+ * @return bool
+ */
+ public function uses_simple_data() {
+ return $this->simpledata;
+ }
+
/**
* Returns true if this definition requires a data guarantee from the cache stores being used.
* @return bool
* @param stdClass|array $data
*/
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.
// Used to store processed lang files.
'string' => array(
'mode' => cache_store::MODE_APPLICATION,
+ 'simpledata' => true,
'persistent' => true,
'persistentmaxsize' => 3
),
// Used to store data from the config + config_plugins table in the database.
'config' => array(
'mode' => cache_store::MODE_APPLICATION,
- 'persistent' => true
+ 'persistent' => true,
+ 'simpledata' => true
),
// Event invalidation cache.
'eventinvalidation' => array(
'mode' => cache_store::MODE_APPLICATION,
'persistent' => true,
- 'requiredataguarantee' => true
+ 'requiredataguarantee' => true,
+ 'simpledata' => true,
),
// Cache for question definitions. This is used by the question_bank class.
defined('MOODLE_INTERNAL') || die();
-$version = 2012110101.00; // YYYYMMDD = weekly release date of this DEV branch
+$version = 2012110102.00; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes