Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
cache_config Class Reference

Cache configuration reader. More...

Public Member Functions

 __construct ()
 Please use cache_config\instance to get an instance of the cache config that is ready to be used.
 
 get_all_stores ()
 Returns all of the configured stores.
 
 get_default_lock ()
 Gets the default lock instance.
 
 get_definition_by_id ($id)
 Gets a definition from the config given its name.
 
 get_definition_mappings ()
 Returns all of the known definition mappings.
 
 get_definitions ()
 Returns all the known definitions.
 
 get_definitions_by_store ($storename)
 Returns the definitions mapped into the given store name.
 
 get_lock_for_store ($storename)
 Returns the lock store configuration to use with a given store.
 
 get_locks ()
 Returns an array of the configured locks.
 
 get_mode_mappings ()
 Returns all of the configured mode mappings.
 
 get_site_identifier ()
 Returns the site identifier used by the cache API.
 
 get_stores ($mode, $requirements=0)
 Returns all of the stores that are suitable for the given mode and requirements.
 
 get_stores_for_definition (cache_definition $definition)
 Gets all of the stores that are to be used for the given definition.
 
 load ($configuration=false)
 Loads the configuration file and parses its contents into the expected structure.
 

Static Public Member Functions

static config_file_exists ()
 Checks if the configuration file exists.
 
static instance ()
 Gets an instance of the cache_configuration class.
 

Protected Member Functions

 include_configuration ()
 Includes the configuration file and makes sure it contains the expected bits.
 
 sort_mappings (array $a, array $b)
 Used to sort cache config arrays based upon a sort key.
 

Static Protected Member Functions

static get_config_file_path ()
 Returns the expected path to the configuration file.
 

Protected Attributes

array $configdefinitionmappings = array()
 The definition mappings that have been configured.
 
array $configdefinitions = array()
 The configured definitions as picked up from cache.php files.
 
array $configlocks = array()
 An array of configured cache lock instances.
 
array $configmodemappings = array()
 The configured mode mappings.
 
array $configstores = array()
 The configured stores.
 
string $siteidentifier = null
 The site identifier used when the cache config was last saved.
 

Detailed Description

Cache configuration reader.

This class is used to interact with the cache's configuration. The configuration is stored in the Moodle data directory.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ config_file_exists()

static cache_config::config_file_exists ( )
static

Checks if the configuration file exists.

Return values
boolTrue if it exists

◆ get_all_stores()

cache_config::get_all_stores ( )

Returns all of the configured stores.

Return values
array

◆ get_config_file_path()

static cache_config::get_config_file_path ( )
staticprotected

Returns the expected path to the configuration file.

Return values
stringThe absolute path

◆ get_default_lock()

cache_config::get_default_lock ( )

Gets the default lock instance.

Return values
array
Exceptions
cache_exception

◆ get_definition_by_id()

cache_config::get_definition_by_id ( $id)

Gets a definition from the config given its name.

Parameters
string$id
Return values
bool

◆ get_definition_mappings()

cache_config::get_definition_mappings ( )

Returns all of the known definition mappings.

Return values
array

◆ get_definitions()

cache_config::get_definitions ( )

Returns all the known definitions.

Return values
array

◆ get_definitions_by_store()

cache_config::get_definitions_by_store ( $storename)

Returns the definitions mapped into the given store name.

Parameters
string$storename
Return values
arrayAssociative array of definitions, id=>definition

◆ get_lock_for_store()

cache_config::get_lock_for_store ( $storename)

Returns the lock store configuration to use with a given store.

Parameters
string$storename
Return values
array
Exceptions
cache_exception

◆ get_locks()

cache_config::get_locks ( )

Returns an array of the configured locks.

Return values
arrayArray of name => config

◆ get_mode_mappings()

cache_config::get_mode_mappings ( )

Returns all of the configured mode mappings.

Return values
array

◆ get_site_identifier()

cache_config::get_site_identifier ( )

Returns the site identifier used by the cache API.

Return values
string

◆ get_stores()

cache_config::get_stores ( $mode,
$requirements = 0 )

Returns all of the stores that are suitable for the given mode and requirements.

Parameters
int$modeOne of cache_store\MODE_*
int$requirementsThe requirements of the cache as a binary flag
Return values
arrayAn array of suitable stores.

◆ get_stores_for_definition()

cache_config::get_stores_for_definition ( cache_definition $definition)

Gets all of the stores that are to be used for the given definition.

Parameters
cache_definition$definition
Return values
array

◆ include_configuration()

cache_config::include_configuration ( )
protected

Includes the configuration file and makes sure it contains the expected bits.

You need to ensure that the config file exists before this is called.

Return values
array
Exceptions
cache_exception

◆ instance()

static cache_config::instance ( )
static

Gets an instance of the cache_configuration class.

Return values
cache_config

◆ load()

cache_config::load ( $configuration = false)

Loads the configuration file and parses its contents into the expected structure.

Parameters
array | false$configurationCan be used to force a configuration. Should only be used when truly required.
Return values
boolean

◆ sort_mappings()

cache_config::sort_mappings ( array $a,
array $b )
protected

Used to sort cache config arrays based upon a sort key.

Highest number at the top.

Parameters
array$a
array$b
Return values
int

The documentation for this class was generated from the following file: