From fdff8077e068158b76fe81081a64a91deff88fee Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Tue, 23 Feb 2016 14:22:58 +1100 Subject: [PATCH] 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. --- cache/classes/loaders.php | 3 +-- cache/classes/store.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cache/classes/loaders.php b/cache/classes/loaders.php index 8bc486fd556..084deb90cb9 100644 --- a/cache/classes/loaders.php +++ b/cache/classes/loaders.php @@ -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; diff --git a/cache/classes/store.php b/cache/classes/store.php index 3a039630cc6..c415ba98e09 100644 --- a/cache/classes/store.php +++ b/cache/classes/store.php @@ -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.