MDL-36362 cache: added simpledata definition option

This commit is contained in:
Sam Hemelryk
2012-11-05 10:28:07 +13:00
parent 6109f2112c
commit 2e1e266c9a
5 changed files with 32 additions and 3 deletions
+21
View File
@@ -39,6 +39,8 @@ defined('MOODLE_INTERNAL') || die();
* [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
@@ -127,6 +129,12 @@ class cache_definition {
*/
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
@@ -281,6 +289,7 @@ class cache_definition {
$area = (string)$definition['area'];
// Set the defaults.
$simpledata = false;
$requireidentifiers = array();
$requiredataguarantee = false;
$requiremultipleidentifiers = false;
@@ -297,6 +306,9 @@ class cache_definition {
$mappingsonly = false;
$invalidationevents = array();
if (array_key_exists('simpledata', $definition)) {
$simpledata = (bool)$definition['simpledata'];
}
if (array_key_exists('requireidentifiers', $definition)) {
$requireidentifiers = (array)$definition['requireidentifiers'];
}
@@ -398,6 +410,7 @@ class cache_definition {
$cachedefinition->mode = $mode;
$cachedefinition->component = $component;
$cachedefinition->area = $area;
$cachedefinition->simpledata = $simpledata;
$cachedefinition->requireidentifiers = $requireidentifiers;
$cachedefinition->requiredataguarantee = $requiredataguarantee;
$cachedefinition->requiremultipleidentifiers = $requiremultipleidentifiers;
@@ -534,6 +547,14 @@ class cache_definition {
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