MDL-25290 cache: Renamed plugin from cache => cachestore

This commit is contained in:
Sam Hemelryk
2012-10-08 09:53:51 +13:00
parent f23fbfd849
commit 6fec18203b
40 changed files with 172 additions and 162 deletions
+2 -2
View File
@@ -498,10 +498,10 @@ if ($hassiteconfig) {
$ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
$ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
$ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
foreach (get_plugin_list('cache') as $plugin => $path) {
foreach (get_plugin_list('cachestore') as $plugin => $path) {
$settingspath = $path.'/settings.php';
if (file_exists($settingspath)) {
$settings = new admin_settingpage('cache_'.$plugin.'_settings', new lang_string('pluginname', 'cache_'.$plugin), 'moodle/site:config');
$settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
include($settingspath);
$ADMIN->add('cachestores', $settings);
}
+2 -2
View File
@@ -126,7 +126,7 @@ class cache_config {
continue;
}
$plugin = $store['plugin'];
$class = 'cache_store_'.$plugin;
$class = 'cachestore_'.$plugin;
if (!array_key_exists($plugin, $availableplugins) && (!class_exists($class) || !is_subclass_of($class, 'cache_store'))) {
// Not a valid plugin, or has been uninstalled, just skip it an carry on.
debugging('Invalid cache store in config. Not an available plugin.', DEBUG_DEVELOPER);
@@ -327,7 +327,7 @@ class cache_config {
if (defined('NO_CACHE_STORES') && NO_CACHE_STORES !== false) {
// Yip its been disabled.
// To facilitate this we are going to always return an empty array of stores to use.
// This will force all cache instances to use the cache_store_dummy.
// This will force all cache instances to use the cachestore_dummy.
// MUC will still be used essentially so that code using it will still continue to function but because no cache stores
// are being used interaction with MUC will be purely based around a static var.
return array();
+2 -2
View File
@@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_dummy implements cache_store {
class cachestore_dummy implements cache_store {
/**
* The name of this store.
@@ -262,7 +262,7 @@ class cache_store_dummy implements cache_store {
* @return false
*/
public static function initialise_test_instance(cache_definition $definition) {
$cache = new cache_store_dummy('Dummy store test');
$cache = new cachestore_dummy('Dummy store test');
$cache->initialise($definition);
return $cache;;
}
+2 -2
View File
@@ -295,12 +295,12 @@ class cache_factory {
* Creates a dummy store object for use when a loader has no potential stores to use.
*
* @param cache_definition $definition
* @return cache_store_dummy
* @return cachestore_dummy
*/
protected function create_dummy_store(cache_definition $definition) {
global $CFG;
require_once($CFG->dirroot.'/cache/classes/dummystore.php');
$store = new cache_store_dummy();
$store = new cachestore_dummy();
$store->initialise($definition);
return $store;
}
+4 -4
View File
@@ -127,7 +127,7 @@ class cache_helper {
public static function get_cache_stores(cache_definition $definition) {
$instance = cache_config::instance();
$stores = $instance->get_stores_for_definition($definition);
$stores = self::initialise_cache_store_instances($stores, $definition);
$stores = self::initialise_cachestore_instances($stores, $definition);
return $stores;
}
@@ -138,7 +138,7 @@ class cache_helper {
* @param cache_definition $definition
* @return array
*/
protected static function initialise_cache_store_instances(array $stores, cache_definition $definition) {
protected static function initialise_cachestore_instances(array $stores, cache_definition $definition) {
$return = array();
$factory = cache_factory::instance();
foreach ($stores as $name => $details) {
@@ -154,14 +154,14 @@ class cache_helper {
* Returns the cache store to be used for locking or false if there is not one.
* @return cache_store|boolean
*/
public static function get_cache_store_for_locking() {
public static function get_cachestore_for_locking() {
$factory = cache_factory::instance();
$definition = $factory->create_definition('core', 'locking');
$instance = cache_config::instance();
$stores = $instance->get_stores_for_definition($definition);
foreach ($stores as $name => $details) {
if ($details['useforlocking']) {
$instances = self::initialise_cache_store_instances(array($name => $details), $definition);
$instances = self::initialise_cachestore_instances(array($name => $details), $definition);
return reset($instances);
}
}
+1 -1
View File
@@ -1083,7 +1083,7 @@ class cache_application extends cache implements cache_loader_with_locking {
*/
protected function ensure_lock_store_available() {
if ($this->lockstore === null) {
$this->lockstore = cache_helper::get_cache_store_for_locking();
$this->lockstore = cache_helper::get_cachestore_for_locking();
}
}
+3 -2
View File
@@ -115,6 +115,7 @@ class cache_lock {
* Returns an instance of the cache lock class.
*
* @staticvar bool $instance
* @param bool $forceregeneration
* @return cache_lock
*/
protected static function instance($forceregeneration = false) {
@@ -157,7 +158,7 @@ class cache_lock {
/**
* Acquires a lock, of dies trying (jokes).
*
* Read {@see cache_lock::lock()} for full details.
* Read {@link cache_lock::lock()} for full details.
*
* @param string $key
* @param bool $block
@@ -216,7 +217,7 @@ class cache_lock {
/**
* Releases an acquired lock.
*
* For more details see {@see cache_lock::unlock()}
* For more details see {@link cache_lock::unlock()}
*
* @param string $key
* @param bool $forceunlock If set to true the lock will be removed if it exists regardless of whether or not we own it.
+1 -1
View File
@@ -37,7 +37,7 @@ require_once($CFG->dirroot.'/lib/formslib.php');
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_addinstance_form extends moodleform {
class cachestore_addinstance_form extends moodleform {
/**
* The definition of the add instance form
+9
View File
@@ -135,6 +135,15 @@ class cache_ttl_wrapper {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_exception extends moodle_exception {
/**
* Constructs a new exception
*
* @param string $errorcode
* @param string $module
* @param string $link
* @param mixed $a
* @param mixed $debuginfo
*/
public function __construct($errorcode, $module = 'cache', $link = '', $a = NULL, $debuginfo = null) {
parent::__construct($errorcode, $module, $link, $a, $debuginfo);
}
+30 -30
View File
@@ -105,9 +105,9 @@ class cache_config_writer extends cache_config {
if (array_key_exists($name, $this->configstores)) {
throw new cache_exception('Duplicate name specificed for cache plugin instance. You must provide a unique name.');
}
$class = 'cache_store_'.$plugin;
$class = 'cachestore_'.$plugin;
if (!class_exists($class)) {
$plugins = get_plugin_list_with_file('cache', 'lib.php');
$plugins = get_plugin_list_with_file('cachestore', 'lib.php');
if (!array_key_exists($plugin, $plugins)) {
throw new cache_exception('Invalid plugin name specified. The plugin either does not exist or is not a valid cache plugin.');
}
@@ -202,11 +202,11 @@ class cache_config_writer extends cache_config {
if (!array_key_exists($name, $this->configstores)) {
throw new cache_exception('The requested instance does not exist.');
}
$plugins = get_plugin_list_with_file('cache', 'lib.php');
$plugins = get_plugin_list_with_file('cachestore', 'lib.php');
if (!array_key_exists($plugin, $plugins)) {
throw new cache_exception('Invalid plugin name specified. The plugin either does not exist or is not valid.');
}
$class = 'cache_store_.'.$plugin;
$class = 'cachestore_.'.$plugin;
$file = $plugins[$plugin];
if (!class_exists($class)) {
if (file_exists($file)) {
@@ -283,39 +283,39 @@ class cache_config_writer extends cache_config {
'name' => 'default_locking',
'plugin' => 'file',
'configuration' => array(),
'features' => cache_store_file::get_supported_features(),
'features' => cachestore_file::get_supported_features(),
'modes' => cache_store::MODE_APPLICATION,
'useforlocking' => true,
'mappingsonly' => true,
'default' => true,
//'class' => 'cache_store_file'
//'class' => 'cachestore_file'
),
'default_application' => array(
'name' => 'default_application',
'plugin' => 'file',
'configuration' => array(),
'features' => cache_store_file::get_supported_features(),
'features' => cachestore_file::get_supported_features(),
'modes' => cache_store::MODE_APPLICATION,
'default' => true,
//'class' => 'cache_store_file'
//'class' => 'cachestore_file'
),
'default_session' => array(
'name' => 'default_session',
'plugin' => 'session',
'configuration' => array(),
'features' => cache_store_session::get_supported_features(),
'features' => cachestore_session::get_supported_features(),
'modes' => cache_store::MODE_SESSION,
'default' => true,
//'class' => 'cache_store_session'
//'class' => 'cachestore_session'
),
'default_request' => array(
'name' => 'default_request',
'plugin' => 'static',
'configuration' => array(),
'features' => cache_store_static::get_supported_features(),
'features' => cachestore_static::get_supported_features(),
'modes' => cache_store::MODE_REQUEST,
'default' => true,
//'class' => 'cache_store_static'
//'class' => 'cachestore_static'
)
);
$writer->configdefinitions = self::locate_definitions();
@@ -539,11 +539,11 @@ abstract class cache_administration_helper extends cache_helper {
*/
public static function get_plugin_summaries() {
$return = array();
$plugins = get_plugin_list_with_file('cache', 'lib.php', true);
$plugins = get_plugin_list_with_file('cachestore', 'lib.php', true);
foreach ($plugins as $plugin => $path) {
$class = 'cache_store_'.$plugin;
$class = 'cachestore_'.$plugin;
$return[$plugin] = array(
'name' => get_string('pluginname', 'cache_'.$plugin),
'name' => get_string('pluginname', 'cachestore_'.$plugin),
'requirementsmet' => $class::are_requirements_met(),
'instances' => 0,
'modes' => array(
@@ -710,19 +710,19 @@ abstract class cache_administration_helper extends cache_helper {
* Returns a form that can be used to add a store instance.
*
* @param string $plugin The plugin to add an instance of
* @return cache_store_addinstance_form
* @return cachestore_addinstance_form
* @throws coding_exception
*/
public static function get_add_store_form($plugin) {
global $CFG; // Needed for includes
$plugindir = get_plugin_directory('cache', $plugin);
$class = 'cache_store_addinstance_form';
$plugindir = get_plugin_directory('cachestore', $plugin);
$class = 'cachestore_addinstance_form';
if (file_exists($plugindir.'/addinstanceform.php')) {
require_once($plugindir.'/addinstanceform.php');
if (class_exists('cache_store_'.$plugin.'_addinstance_form')) {
$class = 'cache_store_'.$plugin.'_addinstance_form';
if (!array_key_exists('cache_store_addinstance_form', class_parents($class))) {
throw new coding_exception('Cache plugin add instance forms must extend cache_store_addinstance_form');
if (class_exists('cachestore_'.$plugin.'_addinstance_form')) {
$class = 'cachestore_'.$plugin.'_addinstance_form';
if (!array_key_exists('cachestore_addinstance_form', class_parents($class))) {
throw new coding_exception('Cache plugin add instance forms must extend cachestore_addinstance_form');
}
}
}
@@ -736,19 +736,19 @@ abstract class cache_administration_helper extends cache_helper {
*
* @param string $plugin
* @param string $store
* @return cache_store_addinstance_form
* @return cachestore_addinstance_form
* @throws coding_exception
*/
public static function get_edit_store_form($plugin, $store) {
global $CFG; // Needed for includes
$plugindir = get_plugin_directory('cache', $plugin);
$class = 'cache_store_addinstance_form';
$plugindir = get_plugin_directory('cachestore', $plugin);
$class = 'cachestore_addinstance_form';
if (file_exists($plugindir.'/addinstanceform.php')) {
require_once($plugindir.'/addinstanceform.php');
if (class_exists('cache_store_'.$plugin.'_addinstance_form')) {
$class = 'cache_store_'.$plugin.'_addinstance_form';
if (!array_key_exists('cache_store_addinstance_form', class_parents($class))) {
throw new coding_exception('Cache plugin add instance forms must extend cache_store_addinstance_form');
if (class_exists('cachestore_'.$plugin.'_addinstance_form')) {
$class = 'cachestore_'.$plugin.'_addinstance_form';
if (!array_key_exists('cachestore_addinstance_form', class_parents($class))) {
throw new coding_exception('Cache plugin add instance forms must extend cachestore_addinstance_form');
}
}
}
@@ -772,7 +772,7 @@ abstract class cache_administration_helper extends cache_helper {
throw new coding_exception('Invalid cache plugin provided. '.$file);
}
require_once($file);
$class = 'cache_store_'.$data->plugin;
$class = 'cachestore_'.$data->plugin;
$method = 'config_get_configuration_array';
if (!class_exists($class)) {
throw new coding_exception('Invalid cache plugin provided.');
+1 -1
View File
@@ -100,7 +100,7 @@ class core_cache_renderer extends plugin_renderer_base {
$row = new html_table_row(array(
$storename,
get_string('pluginname', 'cache_'.$store['plugin']),
get_string('pluginname', 'cachestore_'.$store['plugin']),
($store['isready'] && $store['requirementsmet']) ? $this->output->pix_icon('i/tick_green_small', '1') : '',
$store['mappings'],
join(', ', $modes),
+8 -8
View File
@@ -20,7 +20,7 @@
* This file is part of the file cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_file
* @package cachestore_file
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -35,7 +35,7 @@ require_once($CFG->dirroot.'/cache/stores/file/lib.php');
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_file_addinstance_form extends cache_store_addinstance_form {
class cachestore_file_addinstance_form extends cachestore_addinstance_form {
/**
* Adds the desired form elements.
@@ -43,17 +43,17 @@ class cache_store_file_addinstance_form extends cache_store_addinstance_form {
protected function configuration_definition() {
$form = $this->_form;
$form->addElement('text', 'path', get_string('path', 'cache_file'));
$form->addElement('text', 'path', get_string('path', 'cachestore_file'));
$form->setType('path', PARAM_SAFEPATH);
$form->addHelpButton('path', 'path', 'cache_file');
$form->addHelpButton('path', 'path', 'cachestore_file');
$form->addElement('checkbox', 'autocreate', get_string('autocreate', 'cache_file'));
$form->addElement('checkbox', 'autocreate', get_string('autocreate', 'cachestore_file'));
$form->setType('autocreate', PARAM_BOOL);
$form->addHelpButton('autocreate', 'autocreate', 'cache_file');
$form->addHelpButton('autocreate', 'autocreate', 'cachestore_file');
$form->disabledIf('autocreate', 'path', 'eq', '');
$form->addElement('checkbox', 'prescan', get_string('prescan', 'cache_file'));
$form->addElement('checkbox', 'prescan', get_string('prescan', 'cachestore_file'));
$form->setType('prescan', PARAM_BOOL);
$form->addHelpButton('prescan', 'prescan', 'cache_file');
$form->addHelpButton('prescan', 'prescan', 'cachestore_file');
}
}
@@ -20,7 +20,7 @@
* This file is part of the file cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_file
* @package cachestore_file
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+6 -6
View File
@@ -20,7 +20,7 @@
* This file is part of the file cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_file
* @package cachestore_file
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -37,7 +37,7 @@
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_file implements cache_store, cache_is_lockable, cache_is_key_aware {
class cachestore_file implements cache_store, cache_is_lockable, cache_is_key_aware {
/**
* The name of the store.
@@ -124,7 +124,7 @@ class cache_store_file implements cache_store, cache_is_lockable, cache_is_key_a
debugging('The given file cache store path is not writable. '.$path, DEBUG_DEVELOPER);
}
} else {
$path = make_cache_directory('cache_store_file/'.preg_replace('#[^a-zA-Z0-9\.\-_]+#', '', $name));
$path = make_cache_directory('cachestore_file/'.preg_replace('#[^a-zA-Z0-9\.\-_]+#', '', $name));
}
$this->isready = $path !== false;
$this->path = $path;
@@ -581,12 +581,12 @@ class cache_store_file implements cache_store, cache_is_lockable, cache_is_key_a
* Returns an instance of the cache store, or false if one cannot be created.
*
* @param cache_definition $definition
* @return cache_store_file
* @return cachestore_file
*/
public static function initialise_test_instance(cache_definition $definition) {
$name = 'File test';
$path = make_cache_directory('cache_store_file_test');
$cache = new cache_store_file($name, array('path' => $path));
$path = make_cache_directory('cachestore_file_test');
$cache = new cachestore_file($name, array('path' => $path));
$cache->initialise($definition);
return $cache;
}
+2 -2
View File
@@ -19,7 +19,7 @@
*
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_file
* @package cachestore_file
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -29,4 +29,4 @@ defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012091000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012090700; // Requires this Moodle version
$plugin->component = 'cache_file'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'cachestore_file'; // Full name of the plugin (used for diagnostics)
+4 -4
View File
@@ -19,7 +19,7 @@
*
* This file is part of the memcache cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcache
* @package cachestore_memcache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -35,15 +35,15 @@ require_once($CFG->dirroot.'/cache/stores/memcached/lib.php');
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_memcache_addinstance_form extends cache_store_addinstance_form {
class cachestore_memcache_addinstance_form extends cachestore_addinstance_form {
/**
* Add the desired form elements.
*/
protected function configuration_definition() {
$form = $this->_form;
$form->addElement('textarea', 'servers', get_string('servers', 'cache_memcache'), array('cols' => 75, 'rows' => 5));
$form->addHelpButton('servers', 'servers', 'cache_memcache');
$form->addElement('textarea', 'servers', get_string('servers', 'cachestore_memcache'), array('cols' => 75, 'rows' => 5));
$form->addHelpButton('servers', 'servers', 'cachestore_memcache');
$form->addRule('servers', get_string('required'), 'required');
$form->setType('servers', PARAM_RAW);
}
@@ -19,7 +19,7 @@
*
* This file is part of the memcache cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcache
* @package cachestore_memcache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+4 -4
View File
@@ -19,7 +19,7 @@
*
* This file is part of the memcache cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcache
* @package cachestore_memcache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_memcache implements cache_store {
class cachestore_memcache implements cache_store {
/**
* The name of the store
@@ -349,7 +349,7 @@ class cache_store_memcache implements cache_store {
return false;
}
$config = get_config('cache_memcache');
$config = get_config('cachestore_memcache');
if (empty($config->testservers)) {
return false;
}
@@ -357,7 +357,7 @@ class cache_store_memcache implements cache_store {
$configuration = array();
$configuration['servers'] = explode("\n", $config->testservers);
$store = new cache_store_memcache('Test memcache', $configuration);
$store = new cachestore_memcache('Test memcache', $configuration);
$store->initialise($definition);
return $store;
+2 -2
View File
@@ -19,11 +19,11 @@
*
* This file is part of the memcache cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcache
* @package cachestore_memcache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtextarea('cache_memcache/testservers', new lang_string('testservers', 'cache_memcache'), new lang_string('testservers_desc', 'cache_memcache'), '', PARAM_RAW, 60, 3));
$settings->add(new admin_setting_configtextarea('cachestore_memcache/testservers', new lang_string('testservers', 'cachestore_memcache'), new lang_string('testservers_desc', 'cachestore_memcache'), '', PARAM_RAW, 60, 3));
+2 -2
View File
@@ -19,7 +19,7 @@
*
* Not to be confused with the memcached plugin.
*
* @package cache_memcache
* @package cachestore_memcache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -28,4 +28,4 @@ defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012091000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012090700; // Requires this Moodle version
$plugin->component = 'cache_memcache'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'cachestore_memcache'; // Full name of the plugin (used for diagnostics)
+14 -14
View File
@@ -19,7 +19,7 @@
*
* This file is part of the memcached cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcached
* @package cachestore_memcached
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -35,7 +35,7 @@ require_once($CFG->dirroot.'/cache/stores/memcached/lib.php');
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_memcached_addinstance_form extends cache_store_addinstance_form {
class cachestore_memcached_addinstance_form extends cachestore_addinstance_form {
/**
* Adds the desired form elements.
@@ -43,33 +43,33 @@ class cache_store_memcached_addinstance_form extends cache_store_addinstance_for
protected function configuration_definition() {
$form = $this->_form;
$form->addElement('textarea', 'servers', get_string('servers', 'cache_memcached'), array('cols' => 75, 'rows' => 5));
$form->addHelpButton('servers', 'servers', 'cache_memcached');
$form->addElement('textarea', 'servers', get_string('servers', 'cachestore_memcached'), array('cols' => 75, 'rows' => 5));
$form->addHelpButton('servers', 'servers', 'cachestore_memcached');
$form->addRule('servers', get_string('required'), 'required');
$form->setType('servers', PARAM_RAW);
$form->addElement('selectyesno', 'compression', get_string('usecompression', 'cache_memcached'));
$form->addHelpButton('compression', 'usecompression', 'cache_memcached');
$form->addElement('selectyesno', 'compression', get_string('usecompression', 'cachestore_memcached'));
$form->addHelpButton('compression', 'usecompression', 'cachestore_memcached');
$form->setDefault('compression', 1);
$form->setType('compression', PARAM_BOOL);
$form->addElement('select', 'serialiser', get_string('useserialiser', 'cache_memcached'), cache_store_memcached::config_get_serialiser_options());
$form->addHelpButton('serialiser', 'useserialiser', 'cache_memcached');
$form->addElement('select', 'serialiser', get_string('useserialiser', 'cachestore_memcached'), cachestore_memcached::config_get_serialiser_options());
$form->addHelpButton('serialiser', 'useserialiser', 'cachestore_memcached');
$form->setDefault('serialiser', Memcached::SERIALIZER_PHP);
$form->setType('serialiser', PARAM_NUMBER);
$form->addElement('text', 'prefix', get_string('prefix', 'cache_memcached'), array('size' => 16));
$form->addElement('text', 'prefix', get_string('prefix', 'cachestore_memcached'), array('size' => 16));
$form->setType('prefix', PARAM_ALPHANUM);
$form->addHelpButton('prefix', 'prefix', 'cache_memcached');
$form->addHelpButton('prefix', 'prefix', 'cachestore_memcached');
$form->addElement('select', 'hash', get_string('hash', 'cache_memcached'), cache_store_memcached::config_get_hash_options());
$form->addHelpButton('hash', 'hash', 'cache_memcached');
$form->addElement('select', 'hash', get_string('hash', 'cachestore_memcached'), cachestore_memcached::config_get_hash_options());
$form->addHelpButton('hash', 'hash', 'cachestore_memcached');
$form->setDefault('serialiser', Memcached::HASH_DEFAULT);
$form->setType('serialiser', PARAM_INT);
$form->addElement('selectyesno', 'bufferwrites', get_string('bufferwrites', 'cache_memcached'));
$form->addHelpButton('bufferwrites', 'bufferwrites', 'cache_memcached');
$form->addElement('selectyesno', 'bufferwrites', get_string('bufferwrites', 'cachestore_memcached'));
$form->addHelpButton('bufferwrites', 'bufferwrites', 'cachestore_memcached');
$form->setDefault('bufferwrites', 0);
$form->setType('bufferwrites', PARAM_BOOL);
}
@@ -19,7 +19,7 @@
*
* This file is part of the memcached cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcached
* @package cachestore_memcached
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+16 -16
View File
@@ -19,7 +19,7 @@
*
* This file is part of the memcached cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcached
* @package cachestore_memcached
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -43,7 +43,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_memcached implements cache_store {
class cachestore_memcached implements cache_store {
/**
* The name of the store
@@ -333,13 +333,13 @@ class cache_store_memcached implements cache_store {
*/
public static function config_get_serialiser_options() {
$options = array(
Memcached::SERIALIZER_PHP => get_string('serialiser_php', 'cache_memcached')
Memcached::SERIALIZER_PHP => get_string('serialiser_php', 'cachestore_memcached')
);
if (Memcached::HAVE_JSON) {
$options[Memcached::SERIALIZER_JSON] = get_string('serialiser_json', 'cache_memcached');
$options[Memcached::SERIALIZER_JSON] = get_string('serialiser_json', 'cachestore_memcached');
}
if (Memcached::HAVE_IGBINARY) {
$options[Memcached::SERIALIZER_IGBINARY] = get_string('serialiser_php', 'cache_memcached');
$options[Memcached::SERIALIZER_IGBINARY] = get_string('serialiser_php', 'cachestore_memcached');
}
return $options;
}
@@ -350,15 +350,15 @@ class cache_store_memcached implements cache_store {
*/
public static function config_get_hash_options() {
$options = array(
Memcached::HASH_DEFAULT => get_string('hash_default', 'cache_memcached'),
Memcached::HASH_MD5 => get_string('hash_md5', 'cache_memcached'),
Memcached::HASH_CRC => get_string('hash_crc', 'cache_memcached'),
Memcached::HASH_FNV1_64 => get_string('hash_fnv1_64', 'cache_memcached'),
Memcached::HASH_FNV1A_64 => get_string('hash_fnv1a_64', 'cache_memcached'),
Memcached::HASH_FNV1_32 => get_string('hash_fnv1_32', 'cache_memcached'),
Memcached::HASH_FNV1A_32 => get_string('hash_fnv1a_32', 'cache_memcached'),
Memcached::HASH_HSIEH => get_string('hash_hsieh', 'cache_memcached'),
Memcached::HASH_MURMUR => get_string('hash_murmur', 'cache_memcached'),
Memcached::HASH_DEFAULT => get_string('hash_default', 'cachestore_memcached'),
Memcached::HASH_MD5 => get_string('hash_md5', 'cachestore_memcached'),
Memcached::HASH_CRC => get_string('hash_crc', 'cachestore_memcached'),
Memcached::HASH_FNV1_64 => get_string('hash_fnv1_64', 'cachestore_memcached'),
Memcached::HASH_FNV1A_64 => get_string('hash_fnv1a_64', 'cachestore_memcached'),
Memcached::HASH_FNV1_32 => get_string('hash_fnv1_32', 'cachestore_memcached'),
Memcached::HASH_FNV1A_32 => get_string('hash_fnv1a_32', 'cachestore_memcached'),
Memcached::HASH_HSIEH => get_string('hash_hsieh', 'cachestore_memcached'),
Memcached::HASH_MURMUR => get_string('hash_murmur', 'cachestore_memcached'),
);
return $options;
}
@@ -414,7 +414,7 @@ class cache_store_memcached implements cache_store {
return false;
}
$config = get_config('cache_memcached');
$config = get_config('cachestore_memcached');
if (empty($config->testservers)) {
return false;
}
@@ -437,7 +437,7 @@ class cache_store_memcached implements cache_store {
$configuration['bufferwrites'] = $config->testbufferwrites;
}
$store = new cache_store_memcached('Test memcached', $configuration);
$store = new cachestore_memcached('Test memcached', $configuration);
$store->initialise($definition);
return $store;
+2 -2
View File
@@ -19,11 +19,11 @@
*
* This file is part of the memcached cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_memcached
* @package cachestore_memcached
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtextarea('cache_memcached/testservers', new lang_string('testservers', 'cache_memcached'), new lang_string('testservers_desc', 'cache_memcached'), '', PARAM_RAW, 60, 3));
$settings->add(new admin_setting_configtextarea('cachestore_memcached/testservers', new lang_string('testservers', 'cachestore_memcached'), new lang_string('testservers_desc', 'cachestore_memcached'), '', PARAM_RAW, 60, 3));
+2 -2
View File
@@ -19,7 +19,7 @@
*
* Not to be confused with the memcache plugin.
*
* @package cache_memcached
* @package cachestore_memcached
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -28,4 +28,4 @@ defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012091000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012090700; // Requires this Moodle version
$plugin->component = 'cache_memcached'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'cachestore_memcached'; // Full name of the plugin (used for diagnostics)
+18 -18
View File
@@ -26,7 +26,7 @@
* - usesafe
* - extendedmode
*
* @package cache_mongodb
* @package cachestore_mongodb
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -45,7 +45,7 @@ require_once($CFG->dirroot.'/cache/stores/mongodb/lib.php');
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_mongodb_addinstance_form extends cache_store_addinstance_form {
class cachestore_mongodb_addinstance_form extends cachestore_addinstance_form {
/**
* The forms custom definitions.
@@ -53,45 +53,45 @@ class cache_store_mongodb_addinstance_form extends cache_store_addinstance_form
protected function configuration_definition() {
$form = $this->_form;
$form->addElement('text', 'server', get_string('server', 'cache_mongodb'), array('size' => 72));
$form->addHelpButton('server', 'server', 'cache_mongodb');
$form->addElement('text', 'server', get_string('server', 'cachestore_mongodb'), array('size' => 72));
$form->addHelpButton('server', 'server', 'cachestore_mongodb');
$form->addRule('server', get_string('required'), 'required');
$form->setDefault('server', 'mongodb://127.0.0.1:27017');
$form->setType('server', PARAM_RAW);
$form->addElement('text', 'database', get_string('database', 'cache_mongodb'));
$form->addHelpButton('database', 'database', 'cache_mongodb');
$form->addElement('text', 'database', get_string('database', 'cachestore_mongodb'));
$form->addHelpButton('database', 'database', 'cachestore_mongodb');
$form->addRule('database', get_string('required'), 'required');
$form->setType('database', PARAM_ALPHANUMEXT);
$form->setDefault('database', 'mcache');
$form->addElement('text', 'username', get_string('username', 'cache_mongodb'));
$form->addHelpButton('username', 'username', 'cache_mongodb');
$form->addElement('text', 'username', get_string('username', 'cachestore_mongodb'));
$form->addHelpButton('username', 'username', 'cachestore_mongodb');
$form->setType('username', PARAM_ALPHANUMEXT);
$form->addElement('text', 'password', get_string('password', 'cache_mongodb'));
$form->addHelpButton('password', 'password', 'cache_mongodb');
$form->addElement('text', 'password', get_string('password', 'cachestore_mongodb'));
$form->addHelpButton('password', 'password', 'cachestore_mongodb');
$form->setType('password', PARAM_TEXT);
$form->addElement('text', 'replicaset', get_string('replicaset', 'cache_mongodb'));
$form->addHelpButton('replicaset', 'replicaset', 'cache_mongodb');
$form->addElement('text', 'replicaset', get_string('replicaset', 'cachestore_mongodb'));
$form->addHelpButton('replicaset', 'replicaset', 'cachestore_mongodb');
$form->setType('replicaset', PARAM_ALPHANUMEXT);
$form->setAdvanced('replicaset');
$form->addElement('checkbox', 'usesafe', get_string('usesafe', 'cache_mongodb'));
$form->addHelpButton('usesafe', 'usesafe', 'cache_mongodb');
$form->addElement('checkbox', 'usesafe', get_string('usesafe', 'cachestore_mongodb'));
$form->addHelpButton('usesafe', 'usesafe', 'cachestore_mongodb');
$form->setDefault('usesafe', 1);
$form->setAdvanced('usesafe');
$form->setType('usesafe', PARAM_BOOL);
$form->addElement('text', 'usesafevalue', get_string('usesafevalue', 'cache_mongodb'));
$form->addHelpButton('usesafevalue', 'usesafevalue', 'cache_mongodb');
$form->addElement('text', 'usesafevalue', get_string('usesafevalue', 'cachestore_mongodb'));
$form->addHelpButton('usesafevalue', 'usesafevalue', 'cachestore_mongodb');
$form->disabledIf('usesafevalue', 'usesafe', 'notchecked');
$form->setType('usesafevalue', PARAM_INT);
$form->setAdvanced('usesafevalue');
$form->addElement('checkbox', 'extendedmode', get_string('extendedmode', 'cache_mongodb'));
$form->addHelpButton('extendedmode', 'extendedmode', 'cache_mongodb');
$form->addElement('checkbox', 'extendedmode', get_string('extendedmode', 'cachestore_mongodb'));
$form->addHelpButton('extendedmode', 'extendedmode', 'cachestore_mongodb');
$form->setDefault('extendedmode', 0);
$form->setAdvanced('extendedmode');
$form->setType('extendedmode', PARAM_BOOL);
@@ -17,7 +17,7 @@
/**
* The language strings for the MongoDB store plugin.
*
* @package cache_mongodb
* @package cachestore_mongodb
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+4 -4
View File
@@ -19,7 +19,7 @@
*
* This file is part of the MongoDB store plugin, it contains the API for interacting with an instance of the store.
*
* @package cache_mongodb
* @package cachestore_mongodb
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_mongodb implements cache_store {
class cachestore_mongodb implements cache_store {
/**
* The name of the store
@@ -442,7 +442,7 @@ class cache_store_mongodb implements cache_store {
return false;
}
$config = get_config('cache_mongodb');
$config = get_config('cachestore_mongodb');
if (empty($config->testserver)) {
return false;
}
@@ -468,7 +468,7 @@ class cache_store_mongodb implements cache_store {
$configuration['extendedmode'] = (bool)$config->testextendedmode;
}
$store = new cache_store_mongodb('Test mongodb', $configuration);
$store = new cachestore_mongodb('Test mongodb', $configuration);
$store->initialise($definition);
return $store;
+2 -2
View File
@@ -19,11 +19,11 @@
*
* This file is part of the mongodb cache store, it contains the API for interacting with an instance of the store.
*
* @package cache_mongodb
* @package cachestore_mongodb
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtextarea('cache_mongodb/testserver', new lang_string('testserver', 'cache_mongodb'), new lang_string('testserver_desc', 'cache_mongodb'), '', PARAM_RAW, 60, 3));
$settings->add(new admin_setting_configtextarea('cachestore_mongodb/testserver', new lang_string('testserver', 'cachestore_mongodb'), new lang_string('testserver_desc', 'cachestore_mongodb'), '', PARAM_RAW, 60, 3));
+2 -2
View File
@@ -17,7 +17,7 @@
/**
* Cache mongodb store version information.
*
* @package cache_mongodb
* @package cachestore_mongodb
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -26,4 +26,4 @@ defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012091000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012090700; // Requires this Moodle version
$plugin->component = 'cache_mongodb'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'cachestore_mongodb'; // Full name of the plugin (used for diagnostics)
@@ -20,7 +20,7 @@
* This file is part of the session cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_session
* @package cachestore_session
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+6 -6
View File
@@ -20,7 +20,7 @@
* This file is part of the session cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_session
* @package cachestore_session
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_session extends session_data_store implements cache_store, cache_is_key_aware {
class cachestore_session extends session_data_store implements cache_store, cache_is_key_aware {
/**
* The name of the store
@@ -358,7 +358,7 @@ class cache_store_session extends session_data_store implements cache_store, cac
*/
public static function initialise_test_instance(cache_definition $definition) {
// Do something here perhaps.
$cache = new cache_store_session('Session test');
$cache = new cachestore_session('Session test');
$cache->initialise($definition);
return $cache;
}
@@ -387,10 +387,10 @@ abstract class session_data_store {
protected static function &register_store_id($id) {
if (is_null(self::$sessionstore)) {
global $SESSION;
if (!isset($SESSION->cache_store_session)) {
$SESSION->cache_store_session = array();
if (!isset($SESSION->cachestore_session)) {
$SESSION->cachestore_session = array();
}
self::$sessionstore =& $SESSION->cache_store_session;
self::$sessionstore =& $SESSION->cachestore_session;
}
if (!array_key_exists($id, self::$sessionstore)) {
self::$sessionstore[$id] = array();
+2 -2
View File
@@ -19,7 +19,7 @@
*
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_session
* @package cachestore_session
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -29,4 +29,4 @@ defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012091000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012090700; // Requires this Moodle version
$plugin->component = 'cache_session'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'cachestore_session'; // Full name of the plugin (used for diagnostics)
@@ -20,7 +20,7 @@
* This file is part of the static cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_static
* @package cachestore_static
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+3 -3
View File
@@ -20,7 +20,7 @@
* This file is part of the static cache store, it contains the API for interacting with an instance of the store.
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_static
* @package cachestore_static
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cache_store_static extends static_data_store implements cache_store, cache_is_key_aware {
class cachestore_static extends static_data_store implements cache_store, cache_is_key_aware {
/**
* The name of the store
@@ -358,7 +358,7 @@ class cache_store_static extends static_data_store implements cache_store, cache
*/
public static function initialise_test_instance(cache_definition $definition) {
// Do something here perhaps.
$cache = new cache_store_static('Static store');
$cache = new cachestore_static('Static store');
$cache->initialise($definition);
return $cache;;
}
+2 -2
View File
@@ -19,7 +19,7 @@
*
* This is used as a default cache store within the Cache API. It should never be deleted.
*
* @package cache_static
* @package cachestore_static
* @category cache
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -29,4 +29,4 @@ defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012091000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012090700; // Requires this Moodle version
$plugin->component = 'cache_static'; // Full name of the plugin (used for diagnostics)
$plugin->component = 'cachestore_static'; // Full name of the plugin (used for diagnostics)
+4 -4
View File
@@ -56,10 +56,10 @@ $strunsupportedmode = new lang_string('unsupportedmode', 'cache');
$struntestable = new lang_string('untestable', 'cache');
$strtested = new lang_string('tested', 'cache');
foreach (get_plugin_list_with_file('cache', 'lib.php', true) as $plugin => $path) {
foreach (get_plugin_list_with_file('cachestore', 'lib.php', true) as $plugin => $path) {
$class = 'cache_store_'.$plugin;
$plugin = get_string('pluginname', 'cache_'.$plugin);
$class = 'cachestore_'.$plugin;
$plugin = get_string('pluginname', 'cachestore_'.$plugin);
if (!class_exists($class) || !method_exists($class, 'initialise_test_instance')) {
$applicationtable->data[] = array($plugin, $strinvalidplugin, '-', '-', '-', '-');
@@ -199,4 +199,4 @@ echo html_writer::table($sessiontable);
echo $OUTPUT->heading(get_string('storeresults_request', 'cache'));
echo html_writer::table($requesttable);
echo $OUTPUT->footer();
echo $OUTPUT->footer();
+2 -2
View File
@@ -434,12 +434,12 @@ class cache_phpunit_tests extends advanced_testcase {
// OK data added, data invalidated, and invalidation time has been set.
// Now we need to manually add back the data and adjust the invalidation time.
$timefile = $CFG->dataroot.'/cache/cache_store_file/default_application/phpunit_eventinvalidationtest/494515064.cache';
$timefile = $CFG->dataroot.'/cache/cachestore_file/default_application/phpunit_eventinvalidationtest/494515064.cache';
$timecont = serialize(cache::now() - 60); // Back 60sec in the past to force it to re-invalidate
file_put_contents($timefile, $timecont);
$this->assertTrue(file_exists($timefile));
$datafile = $CFG->dataroot.'/cache/cache_store_file/default_application/phpunit_eventinvalidationtest/3140056538.cache';
$datafile = $CFG->dataroot.'/cache/cachestore_file/default_application/phpunit_eventinvalidationtest/3140056538.cache';
$datacont = serialize("test data 1");
file_put_contents($datafile, $datacont);
$this->assertTrue(file_exists($datafile));
+1 -1
View File
@@ -8011,7 +8011,7 @@ function get_plugin_types($fullpaths=true) {
'qformat' => 'question/format',
'plagiarism' => 'plagiarism',
'tool' => $CFG->admin.'/tool',
'cache' => 'cache/stores',
'cachestore' => 'cache/stores',
'theme' => 'theme', // this is a bit hacky, themes may be in $CFG->themedir too
);
+1 -1
View File
@@ -139,7 +139,7 @@ if (!defined('PHPUNIT_TEST')) {
}
// When set to true MUC (Moodle caching) will not use any of the defined or default stores.
// The Cache API will continue to function however this will force the use of the cache_store_dummy so all requests
// The Cache API will continue to function however this will force the use of the cachestore_dummy so all requests
// will be interacting with a static property and will never go to the proper cache stores.
// Useful if you need to avoid the stores for one reason or another.
if (!defined('NO_CACHE_STORES')) {