Merge branch '43349-27' of git://github.com/samhemelryk/moodle

This commit is contained in:
Dan Poltawski
2014-01-06 14:21:44 +08:00
7 changed files with 14 additions and 26 deletions
-8
View File
@@ -129,14 +129,6 @@ class cachestore_dummy extends cache_store {
return (!empty($this->definition));
}
/**
* Returns true if this is ready.
* @return bool
*/
public function is_ready() {
return true;
}
/**
* Returns true the given mode is supported.
* @param int $mode
+7 -1
View File
@@ -236,6 +236,11 @@ class cache_factory {
public function create_cache(cache_definition $definition) {
$class = $definition->get_cache_class();
$stores = cache_helper::get_stores_suitable_for_definition($definition);
foreach ($stores as $key => $store) {
if (!$store::are_requirements_met()) {
unset($stores[$key]);
}
}
if (count($stores) === 0) {
// Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.
$stores[] = $this->create_dummy_store($definition);
@@ -253,7 +258,7 @@ class cache_factory {
/**
* Creates a store instance given its name and configuration.
*
* If the store has already been instantiated then the original objetc will be returned. (reused)
* If the store has already been instantiated then the original object will be returned. (reused)
*
* @param string $name The name of the store (must be unique remember)
* @param array $details
@@ -267,6 +272,7 @@ class cache_factory {
$store = new $class($details['name'], $details['configuration']);
$this->stores[$name] = $store;
}
/* @var cache_store $store */
$store = $this->stores[$name];
if (!$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) {
return false;
+1
View File
@@ -468,6 +468,7 @@ class cache_helper {
$class = $store['class'];
// Found the store: is it ready?
/* @var cache_store $instance */
$instance = new $class($store['name'], $store['configuration']);
if (!$instance->is_ready()) {
unset($instance);
+3 -1
View File
@@ -179,7 +179,9 @@ abstract class cache_store implements cache_store_interface {
* Returns true if this cache store instance is ready to use.
* @return bool
*/
abstract public function is_ready();
public function is_ready() {
return self::are_requirements_met();
}
/**
* Retrieves an item from the cache store given its key.
-8
View File
@@ -222,14 +222,6 @@ class cachestore_session extends session_data_store implements cache_is_key_awar
return (is_array($this->store));
}
/**
* Returns true if this store instance is ready to be used.
* @return bool
*/
public function is_ready() {
return true;
}
/**
* Retrieves an item from the cache store given its key.
*
-8
View File
@@ -217,14 +217,6 @@ class cachestore_static extends static_data_store implements cache_is_key_aware,
return (is_array($this->store));
}
/**
* Returns true if this store instance is ready to be used.
* @return bool
*/
public function is_ready() {
return true;
}
/**
* Retrieves an item from the cache store given its key.
*
+3
View File
@@ -1,6 +1,9 @@
This files describes API changes in /cache/stores/* - cache store plugins.
Information provided here is intended especially for developers.
=== 2.7 ===
* cache_store::is_ready is no longer abstract, calling cache_store::are_requirements_met by default.
=== 2.6 ===
* All cache instances are recorded and subsequent requests are given a reference to the original instance.
* The persistent option for the cache definition has been deprecated. Please use the staticacceleration option instead.