MDL-36120 cache: now uses sha1 and has an option for simple keys
This commit is contained in:
Vendored
+24
@@ -39,6 +39,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* [int] Sets the mode for the definition. Must be one of cache_store::MODE_*
|
||||
*
|
||||
* Optional settings:
|
||||
* + simplekeys
|
||||
* [bool] Set to true if your cache will only use simple keys for its items.
|
||||
* Simple keys consist of digits, underscores and the 26 chars of the english language. a-zA-Z0-9_
|
||||
* If true the keys won't be hashed before being passed to the cache store for gets/sets/deletes. It will be
|
||||
* better for performance and possible only becase we know the keys are safe.
|
||||
* + simpledata
|
||||
* [bool] If set to true we know that the data is scalar or array of scalar.
|
||||
* + requireidentifiers
|
||||
@@ -129,6 +134,12 @@ class cache_definition {
|
||||
*/
|
||||
protected $area;
|
||||
|
||||
/**
|
||||
* If set to true we know the keys are simple. a-zA-Z0-9_
|
||||
* @var bool
|
||||
*/
|
||||
protected $simplekeys = false;
|
||||
|
||||
/**
|
||||
* Set to true if we know the data is scalar or array of scalar.
|
||||
* @var bool
|
||||
@@ -289,6 +300,7 @@ class cache_definition {
|
||||
$area = (string)$definition['area'];
|
||||
|
||||
// Set the defaults.
|
||||
$simplekeys = false;
|
||||
$simpledata = false;
|
||||
$requireidentifiers = array();
|
||||
$requiredataguarantee = false;
|
||||
@@ -306,6 +318,9 @@ class cache_definition {
|
||||
$mappingsonly = false;
|
||||
$invalidationevents = array();
|
||||
|
||||
if (array_key_exists('simplekeys', $definition)) {
|
||||
$simplekeys = (bool)$definition['simplekeys'];
|
||||
}
|
||||
if (array_key_exists('simpledata', $definition)) {
|
||||
$simpledata = (bool)$definition['simpledata'];
|
||||
}
|
||||
@@ -410,6 +425,7 @@ class cache_definition {
|
||||
$cachedefinition->mode = $mode;
|
||||
$cachedefinition->component = $component;
|
||||
$cachedefinition->area = $area;
|
||||
$cachedefinition->simplekeys = $simplekeys;
|
||||
$cachedefinition->simpledata = $simpledata;
|
||||
$cachedefinition->requireidentifiers = $requireidentifiers;
|
||||
$cachedefinition->requiredataguarantee = $requiredataguarantee;
|
||||
@@ -515,6 +531,14 @@ class cache_definition {
|
||||
return $this->component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PARAM type that best describes the expected keys.
|
||||
* @return bool
|
||||
*/
|
||||
public function uses_simple_keys() {
|
||||
return $this->simplekeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifiers that are being used for this definition.
|
||||
* @return array
|
||||
|
||||
Reference in New Issue
Block a user