MDL-53208 caching: Update serialization rules for performance.

- We only now serialize when required, eg when the store doesn't do it.
- static acceleration now serializes on set to reduce overhead on load.
- null now works in static acceleration as we use an array for storage metadata
- static acceleration delete uses isset rather than an array_search.
This commit is contained in:
Russell Smith
2016-02-28 17:01:51 +11:00
parent 76349f871e
commit fdff8077e0
2 changed files with 2 additions and 3 deletions
+1 -2
View File
@@ -266,7 +266,7 @@ class cache implements cache_loader {
public function set_identifiers(array $identifiers) {
if ($this->definition->set_identifiers($identifiers)) {
// As static acceleration uses input keys and not parsed keys
// if the identifiers are set.
// it much be cleared when the identifier set is changed.
$this->staticaccelerationarray = array();
if ($this->staticaccelerationsize !== false) {
$this->staticaccelerationkeys = array();
@@ -1083,7 +1083,6 @@ class cache implements cache_loader {
// 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.
// Also take care of ttl_wrapping, we need to apply some different serialization rules in that case.
if (is_scalar($data) || $this->definition->uses_simple_data()
|| $data instanceof cache_cached_object) {
$this->staticaccelerationarray[$key]['data'] = $data;
+1 -1
View File
@@ -127,7 +127,7 @@ abstract class cache_store implements cache_store_interface {
const IS_SEARCHABLE = 8;
/**
* The cache store dereferences objects.@global
* The cache store dereferences objects.
*
* When set, loaders will assume that all data coming from this store has already had all references
* resolved. So even for complex object structures it will not try to remove references again.