The cache factory class used when the Cache has been disabled.
More...
|
| create_cache (cache_definition $definition) |
| Common public method to create a cache instance given a definition. More...
|
|
| create_cache_from_definition ($component, $area, array $identifiers=array(), $unused=null) |
| Creates a cache object given the parameters for a definition. More...
|
|
| create_cache_from_params ($mode, $component, $area, array $identifiers=array(), array $options=array()) |
| Creates an ad-hoc cache from the given param. More...
|
|
| create_config_instance ($writer=false) |
| Creates a cache config instance with the ability to write if required. More...
|
|
| create_definition ($component, $area, $unused=null) |
| Creates a definition instance or returns the existing one if it has already been created. More...
|
|
| create_lock_instance (array $config) |
| Returns a lock instance ready for use. More...
|
|
| create_store_from_config ($name, array $details, cache_definition $definition) |
| Creates a store instance given its name and configuration. More...
|
|
| get_adhoc_caches_in_use () |
| Gets all adhoc caches that have been used within this request. More...
|
|
| get_caches_in_use () |
| Returns the cache instances that have been used within this request. More...
|
|
| get_state () |
| Returns the current state of the cache API. More...
|
|
| get_store_instances_in_use (cache_definition $definition) |
| Returns an array of cache stores that have been initialised for use in definitions. More...
|
|
| is_disabled () |
| Returns true if the cache API has been disabled. More...
|
|
| is_initialising () |
| Returns true if the cache is currently initialising itself. More...
|
|
| is_updating () |
| Returns true if the cache is currently updating itself. More...
|
|
| reset_cache_instances () |
| Resets the stores, clearing the array of created stores. More...
|
|
| set_state ($state) |
| Updates the state fo the cache API. More...
|
|
| stores_disabled () |
| Returns true if the cache stores have been disabled. More...
|
|
| updating_finished () |
| Informs the factory that the upgrading has finished. More...
|
|
| updating_started () |
| Informs the factory that the cache is currently updating itself. More...
|
|
|
static | disable_stores () |
| Disables cache stores. More...
|
|
static | instance ($forcereload=false) |
| Returns an instance of the cache_factor method. More...
|
|
static | reset () |
| Resets the arrays containing instantiated caches, stores, and config instances.
|
|
|
const | STATE_DISABLED = 10 |
| The cache has been disabled.
|
|
const | STATE_ERROR_INITIALISING = 9 |
| The cache encountered an error while initialising.
|
|
const | STATE_INITIALISING = 1 |
| The cache is in the process of initialising itself.
|
|
const | STATE_READY = 3 |
| The cache is ready to use.
|
|
const | STATE_SAVING = 2 |
| The cache is in the process of saving its configuration file.
|
|
const | STATE_STORES_DISABLED = 11 |
| The cache stores have been disabled.
|
|
const | STATE_UNINITIALISED = 0 |
| The cache has not been initialised yet.
|
|
const | STATE_UPDATING = 4 |
| The cache is currently updating itself.
|
|
|
static | disable () |
| Disables as much of the cache API as possible. More...
|
|
|
array | $cachesfromdefinitions = array() |
| An array containing caches created for definitions.
|
|
array | $cachesfromparams = array() |
| Array of caches created by parameters, ad-hoc definitions will have been used.
|
|
array | $configs = array() |
| An array of configuration instances.
|
|
array | $definitions = array() |
| An array of initialised definitions.
|
|
array | $definitionstores = array() |
| An array of stores organised by definitions.
|
|
array | $lockplugins = array() |
| An array of lock plugins.
|
|
int | $state = 0 |
| The current state of the cache API.
|
|
array | $stores = array() |
| An array of instantiated stores.
|
|
The cache factory class used when the Cache has been disabled.
- Copyright
- 2012 Sam Hemelryk
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ create_cache()
Common public method to create a cache instance given a definition.
- Parameters
-
- Return values
-
cache_application|cache_session|cache_store | |
- Exceptions
-
Reimplemented from cache_factory.
◆ create_cache_from_definition()
cache_factory_disabled::create_cache_from_definition |
( |
|
$component, |
|
|
|
$area, |
|
|
array |
$identifiers = array() , |
|
|
|
$unused = null |
|
) |
| |
Creates a cache object given the parameters for a definition.
- Parameters
-
string | $component | |
string | $area | |
array | $identifiers | |
string | $unused | Used to be datasourceaggregate but that was removed and this is now unused. |
- Return values
-
cache_application|cache_session|cache_request | |
Reimplemented from cache_factory.
◆ create_cache_from_params()
cache_factory_disabled::create_cache_from_params |
( |
|
$mode, |
|
|
|
$component, |
|
|
|
$area, |
|
|
array |
$identifiers = array() , |
|
|
array |
$options = array() |
|
) |
| |
Creates an ad-hoc cache from the given param.
- Parameters
-
int | $mode | |
string | $component | |
string | $area | |
array | $identifiers | |
array | $options | An array of options, available options are:
- simplekeys : Set to true if the keys you will use are a-zA-Z0-9_
- simpledata : Set to true if the type of the data you are going to store is scalar, or an array of scalar vars
- staticacceleration : If set to true the cache will hold onto all data passing through it.
- staticaccelerationsize : Sets the max size of the static acceleration array.
|
- Return values
-
cache_application|cache_session|cache_request | |
Reimplemented from cache_factory.
◆ create_config_instance()
cache_factory_disabled::create_config_instance |
( |
|
$writer = false | ) |
|
Creates a cache config instance with the ability to write if required.
- Parameters
-
- Return values
-
cache_config_disabled|cache_config_writer | |
Reimplemented from cache_factory.
◆ create_definition()
cache_factory_disabled::create_definition |
( |
|
$component, |
|
|
|
$area, |
|
|
|
$unused = null |
|
) |
| |
Creates a definition instance or returns the existing one if it has already been created.
- Parameters
-
string | $component | |
string | $area | |
string | $unused | Used to be datasourceaggregate but that was removed and this is now unused. |
- Return values
-
Reimplemented from cache_factory.
◆ create_dummy_store()
Creates a dummy store object for use when a loader has no potential stores to use.
- Parameters
-
- Return values
-
◆ create_lock_instance()
cache_factory::create_lock_instance |
( |
array |
$config | ) |
|
|
inherited |
Returns a lock instance ready for use.
- Parameters
-
- Return values
-
◆ create_store_from_config()
cache_factory_disabled::create_store_from_config |
( |
|
$name, |
|
|
array |
$details, |
|
|
cache_definition |
$definition |
|
) |
| |
Creates a store instance given its name and configuration.
- Parameters
-
- Return values
-
Reimplemented from cache_factory.
◆ disable()
static cache_factory::disable |
( |
| ) |
|
|
staticprotectedinherited |
Disables as much of the cache API as possible.
All of the magic associated with the disabled cache is wrapped into this function. In switching out the factory for the disabled factory it gains full control over the initialisation of objects and can use all of the disabled alternatives. Simple!
This function has been marked as protected so that it cannot be abused through the public API presently. Perhaps in the future we will allow this, however as per the build up to the first release containing MUC it was decided that this was just to risky and abusable.
◆ disable_stores()
static cache_factory::disable_stores |
( |
| ) |
|
|
staticinherited |
Disables cache stores.
The cache API will continue to function however none of the actual stores will be used. Instead the dummy store will be provided for all cache requests. This is useful in situations where you cannot be sure any stores are working.
In order to re-enable the cache you must call the cache factories static reset method: // Disable the cache factory. cache_factory::disable_stores(); // Re-enable the cache factory by resetting it. cache_factory::reset();
◆ get_adhoc_caches_in_use()
cache_factory::get_adhoc_caches_in_use |
( |
| ) |
|
|
inherited |
Gets all adhoc caches that have been used within this request.
- Return values
-
cache_store[] | Caches currently in use |
◆ get_caches_in_use()
cache_factory::get_caches_in_use |
( |
| ) |
|
|
inherited |
Returns the cache instances that have been used within this request.
- Since
- Moodle 2.6
- Return values
-
◆ get_state()
cache_factory::get_state |
( |
| ) |
|
|
inherited |
Returns the current state of the cache API.
- Return values
-
◆ get_store_instances_in_use()
Returns an array of cache stores that have been initialised for use in definitions.
- Parameters
-
- Return values
-
◆ instance()
static cache_factory_disabled::instance |
( |
|
$forcereload = false | ) |
|
|
static |
Returns an instance of the cache_factor method.
- Parameters
-
- Return values
-
- Exceptions
-
Reimplemented from cache_factory.
◆ is_disabled()
cache_factory_disabled::is_disabled |
( |
| ) |
|
Returns true if the cache API has been disabled.
- Return values
-
Reimplemented from cache_factory.
◆ is_initialising()
cache_factory::is_initialising |
( |
| ) |
|
|
inherited |
Returns true if the cache is currently initialising itself.
This includes both initialisation and saving the cache config file as part of that initialisation.
- Return values
-
◆ is_updating()
cache_factory::is_updating |
( |
| ) |
|
|
inherited |
Returns true if the cache is currently updating itself.
- Return values
-
◆ reset_cache_instances()
cache_factory::reset_cache_instances |
( |
| ) |
|
|
inherited |
Resets the stores, clearing the array of created stores.
Cache objects still held onto by the code that initialised them will remain as is however all future requests for a cache/store will lead to a new instance being re-initialised.
◆ set_state()
cache_factory::set_state |
( |
|
$state | ) |
|
|
inherited |
Updates the state fo the cache API.
- Parameters
-
- Return values
-
◆ stores_disabled()
cache_factory::stores_disabled |
( |
| ) |
|
|
inherited |
Returns true if the cache stores have been disabled.
- Return values
-
◆ updating_finished()
cache_factory::updating_finished |
( |
| ) |
|
|
inherited |
Informs the factory that the upgrading has finished.
This forces the state back to ready.
◆ updating_started()
cache_factory::updating_started |
( |
| ) |
|
|
inherited |
Informs the factory that the cache is currently updating itself.
This forces the state to upgrading and can only be called once the cache is ready to use. Calling it ensure we don't try to reinstantite things when requesting cache definitions that don't exist yet.
The documentation for this class was generated from the following file: