Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
The APCu cache store class. More...
Public Member Functions | |
__construct ($name, array $configuration=array()) | |
Constructs an instance of the cache store. More... | |
cleanup () | |
create_clone (array $details=array()) | |
Creates a clone of this store instance ready to be initialised. More... | |
delete ($key) | |
Deletes an item from the cache store. More... | |
delete_many (array $keys) | |
Deletes several keys from the cache in a single action. More... | |
get ($key) | |
Retrieves an item from the cache store given its key. More... | |
get_many ($keys) | |
Retrieves several items from the cache store in a single transaction. More... | |
get_warnings () | |
Can be overridden to return any warnings this store instance should make to the admin. More... | |
has ($key) | |
Test is a cache has a key. More... | |
has_all (array $keys) | |
Test is a cache has all of the given keys. More... | |
has_any (array $keys) | |
Test if a cache has at least one of the given keys. More... | |
initialise (cache_definition $definition) | |
Initialises a new instance of the cache store given the definition the instance is to be used for. More... | |
instance_created () | |
Performs any necessary operation when the store instance has been created. More... | |
instance_deleted () | |
Performs any necessary clean up when the store instance is being deleted. | |
is_initialised () | |
Returns true if this cache store instance has been initialised. More... | |
is_ready () | |
Returns true if this cache store instance is ready to use. More... | |
is_searchable () | |
Returns true if the store instance is searchable. More... | |
my_name () | |
Returns the name of this store instance. More... | |
purge () | |
Purges the cache deleting all items within it. More... | |
set ($key, $data) | |
Sets an item in the cache given its key and data value. More... | |
set_many (array $keyvaluearray) | |
Sets many items in the cache in a single transaction. More... | |
supports_data_guarantee () | |
Returns true if the store instance guarantees data. More... | |
supports_dereferencing_objects () | |
Returns true if the store automatically dereferences objects. More... | |
supports_multiple_identifiers () | |
Returns true if the store instance supports multiple identifiers. More... | |
supports_native_ttl () | |
Returns true if the store instance supports native ttl. More... | |
Static Public Member Functions | |
static | are_requirements_met () |
Static method to check that the APCu stores requirements have been met. More... | |
static | can_add_instance () |
Returns true if the user can add an instance of the store plugin. More... | |
static | config_get_configuration_array ($data) |
Given the data from the add instance form this function creates a configuration array. More... | |
static | config_set_edit_form_data (moodleform $editform, array $config) |
Allows the cache store to set its data against the edit form before it is shown to the user. More... | |
static | get_supported_features (array $configuration=array()) |
Returns the supported features as a binary flag. More... | |
static | get_supported_modes (array $configuration=array()) |
Returns the supported modes as a binary flag. More... | |
static | initialise_test_instance (cache_definition $definition) |
Generates an instance of the cache store that can be used for testing. More... | |
static | is_supported_mode ($mode) |
Static method to check if a store is usable with the given mode. More... | |
static | ready_to_be_used_for_testing () |
Returns true if this cache store instance is both suitable for testing, and ready for testing. More... | |
static | unit_test_configuration () |
Generates the appropriate configuration required for unit testing. More... | |
Public Attributes | |
const | DEREFERENCES_OBJECTS = 16 |
The cache store dereferences objects. More... | |
const | IS_SEARCHABLE = 8 |
The cache is searchable by key. | |
const | MODE_APPLICATION = 1 |
Application caches. More... | |
const | MODE_REQUEST = 4 |
Request caches. More... | |
const | MODE_SESSION = 2 |
Session caches. More... | |
const | REQUIRED_VERSION = '4.0.0' |
The required version of APCu for this extension. | |
const | SUPPORTS_DATA_GUARANTEE = 2 |
Ensures data remains in the cache once set. | |
const | SUPPORTS_MULTIPLE_IDENTIFIERS = 1 |
Supports multi-part keys. | |
const | SUPPORTS_NATIVE_TTL = 4 |
Supports a native ttl system. | |
Protected Member Functions | |
prepare_key ($key) | |
Prepares the given key for use. More... | |
Protected Attributes | |
string | $cacheprefix = null |
The prefix added specifically for this cache. | |
cache_definition | $definition = null |
The definition used when this instance was initialised. | |
string | $name |
The name of this store instance. | |
string | $storeprefix = null |
The storeprefix to use on all instances of this store. More... | |
The APCu cache store class.
cachestore_apcu::__construct | ( | $name, | |
array | $configuration = array() |
||
) |
Constructs an instance of the cache store.
This method should not create connections or perform and processing, it should be used
string | $name | The name of the cache store |
array | $configuration | The configuration for this store instance. |
Reimplemented from cache_store.
|
static |
Static method to check that the APCu stores requirements have been met.
It checks that the APCu extension has been loaded and that it has been enabled.
bool | True if the stores software/hardware requirements have been met and it can be used. False otherwise. |
Implements cache_store_interface.
|
staticinherited |
Returns true if the user can add an instance of the store plugin.
bool |
Reimplemented in cachestore_static, cachestore_session, and cachestore_dummy.
|
inherited |
|
static |
Given the data from the add instance form this function creates a configuration array.
stdClass | $data |
array |
Implements cache_is_configurable.
|
static |
Allows the cache store to set its data against the edit form before it is shown to the user.
moodleform | $editform | |
array | $config |
Implements cache_is_configurable.
|
inherited |
Creates a clone of this store instance ready to be initialised.
This method is used so that a cache store needs only be constructed once. Future requests for an instance of the store will be given a cloned instance.
If you are writing a cache store that isn't compatible with the clone operation you can override this method to handle any situations you want before cloning.
array | $details | An array containing the details of the store from the cache config. |
cache_store |
cachestore_apcu::delete | ( | $key | ) |
Deletes an item from the cache store.
string | $key | The key to delete. |
bool | Returns true if the operation was a success, false otherwise. |
Reimplemented from cache_store.
cachestore_apcu::delete_many | ( | array | $keys | ) |
Deletes several keys from the cache in a single action.
array | $keys | The keys to delete |
int | The number of items successfully deleted. |
Reimplemented from cache_store.
cachestore_apcu::get | ( | $key | ) |
Retrieves an item from the cache store given its key.
string | $key | The key to retrieve |
mixed | The data that was associated with the key, or false if the key did not exist. |
Reimplemented from cache_store.
cachestore_apcu::get_many | ( | $keys | ) |
Retrieves several items from the cache store in a single transaction.
If not all of the items are available in the cache then the data value for those that are missing will be set to false.
array | $keys | The array of keys to retrieve |
array | An array of items from the cache. There will be an item for each key, those that were not in the store will be set to false. |
Reimplemented from cache_store.
|
static |
Returns the supported features as a binary flag.
array | $configuration | The configuration of a store to consider specifically. |
int | The supported features. |
Implements cache_store_interface.
|
static |
Returns the supported modes as a binary flag.
array | $configuration | The configuration of a store to consider specifically. |
int | The supported modes. |
Implements cache_store_interface.
|
inherited |
Can be overridden to return any warnings this store instance should make to the admin.
This should be used to notify things like configuration conflicts etc. The warnings returned here will be displayed on the cache configuration screen.
string[] | An array of warning strings from the store instance. |
Reimplemented in cachestore_memcached.
cachestore_apcu::has | ( | $key | ) |
Test is a cache has a key.
string | int | $key |
bool | True if the cache has the requested key, false otherwise. |
Implements cache_is_key_aware.
cachestore_apcu::has_all | ( | array | $keys | ) |
Test is a cache has all of the given keys.
array | $keys |
bool | True if the cache has all of the given keys, false otherwise. |
Implements cache_is_key_aware.
cachestore_apcu::has_any | ( | array | $keys | ) |
Test if a cache has at least one of the given keys.
array | $keys |
bool | True if the cache has at least one of the given keys |
Implements cache_is_key_aware.
cachestore_apcu::initialise | ( | cache_definition | $definition | ) |
Initialises a new instance of the cache store given the definition the instance is to be used for.
This function should prepare any given connections etc.
cache_definition | $definition |
bool |
Reimplemented from cache_store.
|
static |
Generates an instance of the cache store that can be used for testing.
Returns an instance of the cache store, or false if one cannot be created.
cache_definition | $definition |
cache_store |
Implements cache_store_interface.
|
inherited |
Performs any necessary operation when the store instance has been created.
Reimplemented in cachestore_file.
cachestore_apcu::is_initialised | ( | ) |
Returns true if this cache store instance has been initialised.
bool |
Reimplemented from cache_store.
|
inherited |
Returns true if this cache store instance is ready to use.
bool |
Reimplemented in cachestore_redis, cachestore_mongodb, cachestore_memcached, and cachestore_file.
|
inherited |
Returns true if the store instance is searchable.
bool |
|
static |
Static method to check if a store is usable with the given mode.
int | $mode | One of cache_store::MODE_* |
bool | True if the mode is supported. |
Implements cache_store_interface.
cachestore_apcu::my_name | ( | ) |
|
protected |
Prepares the given key for use.
Should be called before all interaction.
string | $key | The key to prepare for storing in APCu. |
string |
cachestore_apcu::purge | ( | ) |
Purges the cache deleting all items within it.
boolean | True on success. False otherwise. |
Reimplemented from cache_store.
|
static |
Returns true if this cache store instance is both suitable for testing, and ready for testing.
Cache stores that support being used as the default store for unit and acceptance testing should override this function and return true if there requirements have been met.
bool |
Reimplemented from cache_store.
cachestore_apcu::set | ( | $key, | |
$data | |||
) |
Sets an item in the cache given its key and data value.
string | $key | The key to use. |
mixed | $data | The data to set. |
bool | True if the operation was a success false otherwise. |
Reimplemented from cache_store.
cachestore_apcu::set_many | ( | array | $keyvaluearray | ) |
Sets many items in the cache in a single transaction.
array | $keyvaluearray | An array of key value pairs. Each item in the array will be an associative array with two keys, 'key' and 'value'. |
int | The number of items successfully set. It is up to the developer to check this matches the number of items sent ... if they care that is. |
Reimplemented from cache_store.
|
inherited |
Returns true if the store instance guarantees data.
bool |
|
inherited |
Returns true if the store automatically dereferences objects.
bool |
|
inherited |
Returns true if the store instance supports multiple identifiers.
bool |
Reimplemented in cachestore_static, cachestore_session, cachestore_mongodb, cachestore_memcached, and cachestore_file.
|
inherited |
Returns true if the store instance supports native ttl.
bool |
|
static |
Generates the appropriate configuration required for unit testing.
array | Array of unit test configuration data to be used by initialise(). |
Implements cache_store_interface.
|
protected |
The storeprefix to use on all instances of this store.
Configured as part store setup.
|
inherited |
The cache store dereferences objects.
When set, loaders will assume that all data coming from this store has already had all references resolved. So even for complex object structures it will not try to remove references again.
|
inherited |
Application caches.
These are shared caches.
|
inherited |
Request caches.
Static caches really.
|
inherited |
Session caches.
Just access to the PHP session.