throw new coding_exception('You must provide a mode when creating a cache definition');
}
if (!array_key_exists('component', $definition)) {
- throw new coding_exception('You must provide a mode when creating a cache definition');
+ throw new coding_exception('You must provide a component when creating a cache definition');
}
if (!array_key_exists('area', $definition)) {
- throw new coding_exception('You must provide a mode when creating a cache definition');
+ throw new coding_exception('You must provide an area when creating a cache definition');
}
$mode = (int)$definition['mode'];
$component = (string)$definition['component'];
*/
public function get_data_source() {
if (!$this->has_data_source()) {
- throw new coding_exception('This cache does not use a datasource.');
+ throw new coding_exception('This cache does not use a data source.');
}
return forward_static_call(array($this->datasource, 'get_instance_for_cache'), $this);
}
* Returns true if this store supports multiple identifiers.
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return false;
}
*
* Please note that this happens automatically if the cache definition requires locking.
* it is still made a public method so that adhoc caches can use it if they choose.
- * However this doesn't guarantee consistent access. It will become the reponsiblity of the calling code to ensure locks
- * are acquired, checked, and released.
+ * However this doesn't guarantee consistent access. It will become the responsibility of the calling code to ensure
+ * locks are acquired, checked, and released.
*
* @param string|int $key
* @return bool True if the lock could be acquired, false otherwise.
*
* Please note that this happens automatically if the cache definition requires locking.
* it is still made a public method so that adhoc caches can use it if they choose.
- * However this doesn't guarantee consistent access. It will become the reponsiblity of the calling code to ensure locks
- * are acquired, checked, and released.
+ * However this doesn't guarantee consistent access. It will become the responsibility of the calling code to ensure
+ * locks are acquired, checked, and released.
*
* @param string|int $key
* @return bool True if this code has the lock, false if there is a lock but this code doesn't have it,
*
* Please note that this happens automatically if the cache definition requires locking.
* it is still made a public method so that adhoc caches can use it if they choose.
- * However this doesn't guarantee consistent access. It will become the reponsiblity of the calling code to ensure locks
- * are acquired, checked, and released.
+ * However this doesn't guarantee consistent access. It will become the responsibility of the calling code to ensure
+ * locks are acquired, checked, and released.
*
* @param string|int $key
* @return bool True if the lock has been released, false if there was a problem releasing the lock.
*
* @return bool
*/
- public function supports_multiple_indentifiers();
+ public function supports_multiple_identifiers();
/**
* Returns true if this cache store instance promotes data guarantee.
* Cache loaders
*
* This file is part of Moodle's cache API, affectionately called MUC.
- * It contains the components that are requried in order to use caching.
+ * It contains the components that are required in order to use caching.
*
* @package core
* @category cache
*/
protected function parse_key($key) {
// First up if the store supports multiple keys we'll go with that.
- if ($this->store->supports_multiple_indentifiers()) {
+ if ($this->store->supports_multiple_identifiers()) {
$result = $this->definition->generate_multi_key_parts();
$result['key'] = $key;
return $result;
($store->get_supported_modes($return) & cache_store::MODE_REQUEST) == cache_store::MODE_REQUEST,
),
'supports' => array(
- 'multipleidentifiers' => $store->supports_multiple_indentifiers(),
+ 'multipleidentifiers' => $store->supports_multiple_identifiers(),
'dataguarantee' => $store->supports_data_guarantee(),
'nativettl' => $store->supports_native_ttl(),
'nativelocking' => ($store instanceof cache_is_lockable),
*
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return false;
}
* Pre-scan the cache to see which keys are present.
*/
protected function prescan_keys() {
- foreach (glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT) as $filename) {
- $this->keys[basename($filename)] = filemtime($filename);
+ $files = glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT);
+ if (is_array($files)) {
+ foreach ($files as $filename) {
+ $this->keys[basename($filename)] = filemtime($filename);
+ }
}
}
* @return boolean True on success. False otherwise.
*/
public function purge() {
- foreach (glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT) as $filename) {
- @unlink($filename);
+ $files = glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT);
+ if (is_array($files)) {
+ foreach ($files as $filename) {
+ @unlink($filename);
+ }
}
$this->keys = array();
return true;
*
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return false;
}
*
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return false;
}
* Returns true if this store is making use of multiple identifiers.
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return $this->extendedmode;
}
*
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return false;
}
*
* @return bool
*/
- public function supports_multiple_indentifiers() {
+ public function supports_multiple_identifiers() {
return false;
}