MDL-53208 caching: Enable dereferencing as a feature.

If the cache does all the dereferencing when it stores and loads
the objects, then the cache loaders don't need to do that work.
This is true of all caches that use something other than PHP's memory
to store their results.
This commit is contained in:
Russell Smith
2016-02-28 17:01:49 +11:00
parent 5007975d1e
commit b2159f2d3f
6 changed files with 28 additions and 4 deletions
+17
View File
@@ -126,6 +126,14 @@ abstract class cache_store implements cache_store_interface {
*/
const IS_SEARCHABLE = 8;
/**
* The cache store dereferences objects.@global
*
* 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.
*/
const DEREFERENCES_OBJECTS = 16;
// Constants for the modes of a cache store
/**
@@ -334,6 +342,15 @@ abstract class cache_store implements cache_store_interface {
return in_array('cache_is_searchable', class_implements($this));
}
/**
* Returns true if the store automatically dereferences objects.
*
* @return bool
*/
public function supports_dereferencing_objects() {
return $this::get_supported_features() & self::DEREFERENCES_OBJECTS;
}
/**
* Creates a clone of this store instance ready to be initialised.
*