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:
Vendored
+17
@@ -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.
|
||||
*
|
||||
|
||||
Vendored
+2
-1
@@ -211,7 +211,8 @@ class cachestore_file extends cache_store implements cache_is_key_aware, cache_i
|
||||
public static function get_supported_features(array $configuration = array()) {
|
||||
$supported = self::SUPPORTS_DATA_GUARANTEE +
|
||||
self::SUPPORTS_NATIVE_TTL +
|
||||
self::IS_SEARCHABLE;
|
||||
self::IS_SEARCHABLE +
|
||||
self::DEREFERENCES_OBJECTS;
|
||||
return $supported;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -271,7 +271,7 @@ class cachestore_memcache extends cache_store implements cache_is_configurable {
|
||||
* @return int
|
||||
*/
|
||||
public static function get_supported_features(array $configuration = array()) {
|
||||
return self::SUPPORTS_NATIVE_TTL;
|
||||
return self::SUPPORTS_NATIVE_TTL + self::DEREFERENCES_OBJECTS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
-1
@@ -258,7 +258,7 @@ class cachestore_memcached extends cache_store implements cache_is_configurable
|
||||
* @return int
|
||||
*/
|
||||
public static function get_supported_features(array $configuration = array()) {
|
||||
return self::SUPPORTS_NATIVE_TTL;
|
||||
return self::SUPPORTS_NATIVE_TTL + self::DEREFERENCES_OBJECTS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
-1
@@ -175,7 +175,7 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
|
||||
* @return int
|
||||
*/
|
||||
public static function get_supported_features(array $configuration = array()) {
|
||||
$supports = self::SUPPORTS_DATA_GUARANTEE;
|
||||
$supports = self::SUPPORTS_DATA_GUARANTEE + self::DEREFERENCES_OBJECTS;
|
||||
if (array_key_exists('extendedmode', $configuration) && $configuration['extendedmode']) {
|
||||
$supports += self::SUPPORTS_MULTIPLE_IDENTIFIERS;
|
||||
}
|
||||
|
||||
Vendored
+6
@@ -1,6 +1,12 @@
|
||||
This files describes API changes in /cache/stores/* - cache store plugins.
|
||||
Information provided here is intended especially for developers.
|
||||
|
||||
=== 3.1 ===
|
||||
* Cache stores has a new feature DEREFERENCES_OBJECTS.
|
||||
This allows the cache loader to decide if it needs to handle dereferencing or whether the data
|
||||
coming directly to it has already had references resolved.
|
||||
- see supports_dereferencing_objects in store.php.
|
||||
|
||||
=== 2.9 ===
|
||||
* Cache data source aggregation functionality has been removed. This functionality was found to be broken and unused.
|
||||
It was decided that rather than fixing it it should be removed.
|
||||
|
||||
Reference in New Issue
Block a user