Required as it is needed for cache_config_disabled which extends cache_config_writer.
More...
|
static | compare_purge_tokens ($tokena, $tokenb) |
| Compare a pair of purge tokens. More...
|
|
static | get_purge_token ($reset=false) |
| Get a 'purge' token used for cache invalidation handling. More...
|
|
static | make ($component, $area, array $identifiers=array(), $unused=null) |
| Creates a new cache instance for a pre-defined definition. More...
|
|
static | make_from_params ($mode, $component, $area, array $identifiers=array(), array $options=array()) |
| Creates a new cache instance based upon the given params. More...
|
|
static | now ($float=false) |
| Returns the timestamp from the first request for the time from the cache API. More...
|
|
|
bool | $perfdebug = false |
| Gets set to true if we want to collect performance information about the cache API.
|
|
strubg | $storetype = 'unknown' |
| Gets set to the class name of the store during initialisation. More...
|
|
bool | $subloader = false |
| Determines if this loader is a sub loader, not the top of the chain.
|
|
|
static int | $now |
| We need a timestamp to use within the cache API. More...
|
|
static string | $purgetoken |
| A purge token used to distinguish between multiple cache purges in the same second. More...
|
|
Required as it is needed for cache_config_disabled which extends cache_config_writer.
The cache loader 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
◆ __construct()
Constructs the cache.
- Parameters
-
Reimplemented from cache.
◆ compare_purge_tokens()
static cache::compare_purge_tokens |
( |
|
$tokena, |
|
|
|
$tokenb |
|
) |
| |
|
staticinherited |
Compare a pair of purge tokens.
If the two tokens are identical, then the return value is 0. If the time component of token A is newer than token B, then a positive value is returned. If the time component of token B is newer than token A, then a negative value is returned.
Note: This function is intended for use from within the Cache API only and not by plugins, or cache stores.
- Parameters
-
string | $tokena | |
string | $tokenb | |
- Return values
-
◆ deep_clone()
cache::deep_clone |
( |
|
$value | ) |
|
|
protectedinherited |
Creates a reference free clone of the given value.
- Parameters
-
- Return values
-
◆ delete()
cache_disabled::delete |
( |
|
$key, |
|
|
|
$recurse = true |
|
) |
| |
Deletes an item from the cache.
- Parameters
-
int | string | $key | Unused. |
bool | $recurse | Unused. |
- Return values
-
Reimplemented from cache.
◆ delete_from_persist_cache()
cache::delete_from_persist_cache |
( |
| ) |
|
|
protectedinherited |
◆ delete_many()
cache_disabled::delete_many |
( |
array |
$keys, |
|
|
|
$recurse = true |
|
) |
| |
Deletes many items at once from the cache.
- Parameters
-
array | $keys | Unused. |
bool | $recurse | Unused. |
- Return values
-
Reimplemented from cache.
◆ get()
Gets a key from the cache.
- Parameters
-
int | string | $key | |
int | $strictness | Unused. |
- Return values
-
Reimplemented from cache.
◆ get_datasource()
cache::get_datasource |
( |
| ) |
|
|
protectedinherited |
Returns the data source associated with this cache.
- Since
- Moodle 2.4.4
- Return values
-
◆ get_definition()
cache::get_definition |
( |
| ) |
|
|
protectedinherited |
Returns the cache definition.
- Return values
-
◆ get_from_persist_cache()
cache::get_from_persist_cache |
( |
| ) |
|
|
protectedinherited |
◆ get_loader()
Returns the loader associated with this instance.
- Since
- Moodle 2.4.4
- Return values
-
◆ get_many()
cache_disabled::get_many |
( |
array |
$keys, |
|
|
|
$strictness = IGNORE_MISSING |
|
) |
| |
Gets many keys at once from the cache.
- Parameters
-
array | $keys | |
int | $strictness | Unused. |
- Return values
-
Reimplemented from cache.
◆ get_purge_token()
static cache::get_purge_token |
( |
|
$reset = false | ) |
|
|
staticinherited |
Get a 'purge' token used for cache invalidation handling.
Note: This function is intended for use from within the Cache API only and not by plugins, or cache stores.
- Parameters
-
bool | $reset | Whether to reset the token and generate a new one. |
- Return values
-
◆ get_store()
Returns the cache store.
- Return values
-
◆ handle_invalidation_events()
cache::handle_invalidation_events |
( |
| ) |
|
|
protectedinherited |
Process any outstanding invalidation events for the cache we are registering,.
Identifiers and event invalidation are not compatible with each other at this time. As a result the cache does not need to consider identifiers when working out what to invalidate.
◆ has() [1/2]
cache_loader::has |
( |
|
$key | ) |
|
|
inherited |
Test is a cache has a key.
The use of the has methods is strongly discouraged. In a high load environment the cache may well change between the test and any subsequent action (get, set, delete etc). Instead it is recommended to write your code in such a way they it performs the following steps:
-
Attempt to retrieve the information.
-
Generate the information.
-
Attempt to set the information
Its also worth mentioning that not all stores support key tests. For stores that don't support key tests this functionality is mimicked by using the equivalent get method. Just one more reason you should not use these methods unless you have a very good reason to do so.
- Parameters
-
- Return values
-
bool | True if the cache has the requested key, false otherwise. |
◆ has() [2/2]
cache_disabled::has |
( |
|
$key, |
|
|
|
$tryloadifpossible = false |
|
) |
| |
Checks if the cache has the requested key.
- Parameters
-
int | string | $key | Unused. |
bool | $tryloadifpossible | Unused. |
- Return values
-
Reimplemented from cache.
◆ has_a_ttl()
Returns true if the cache is making use of a ttl.
- Return values
-
◆ has_all()
cache_disabled::has_all |
( |
array |
$keys | ) |
|
Checks if the cache has all of the requested keys.
- Parameters
-
- Return values
-
Reimplemented from cache.
◆ has_any()
cache_disabled::has_any |
( |
array |
$keys | ) |
|
Checks if the cache has any of the requested keys.
- Parameters
-
- Return values
-
Reimplemented from cache.
◆ is_in_persist_cache()
cache::is_in_persist_cache |
( |
| ) |
|
|
protectedinherited |
◆ is_using_persist_cache()
cache::is_using_persist_cache |
( |
| ) |
|
|
protectedinherited |
◆ make()
static cache::make |
( |
|
$component, |
|
|
|
$area, |
|
|
array |
$identifiers = array() , |
|
|
|
$unused = null |
|
) |
| |
|
staticinherited |
Creates a new cache instance for a pre-defined definition.
- Parameters
-
string | $component | The component for the definition |
string | $area | The area for the definition |
array | $identifiers | Any additional identifiers that should be provided to the definition. |
string | $unused | Used to be datasourceaggregate but that was removed and this is now unused. |
- Return values
-
cache_application|cache_session|cache_store | |
◆ make_from_params()
static cache::make_from_params |
( |
|
$mode, |
|
|
|
$component, |
|
|
|
$area, |
|
|
array |
$identifiers = array() , |
|
|
array |
$options = array() |
|
) |
| |
|
staticinherited |
Creates a new cache instance based upon the given params.
- Parameters
-
int | $mode | One of cache_store::MODE_* |
string | $component | The component this cache relates to. |
string | $area | The area this cache relates to. |
array | $identifiers | Any additional identifiers that should be provided to the definition. |
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 data passing through it.
- staticaccelerationsize : The max size for the static acceleration array.
|
- Return values
-
cache_application|cache_session|cache_store | |
◆ now()
static cache::now |
( |
|
$float = false | ) |
|
|
staticinherited |
Returns the timestamp from the first request for the time from the cache API.
This stamp needs to be used for all ttl and time based operations to ensure that we don't end up with timing issues.
- Parameters
-
bool | $float | Whether to use floating precision accuracy. |
- Return values
-
◆ parse_key()
Parses the key turning it into a string (or array is required) suitable to be passed to the cache store.
- Parameters
-
string | int | $key | As passed to get|set|delete etc. |
- Return values
-
string|array | String unless the store supports multi-identifiers in which case an array if returned. |
Reimplemented in cache_session.
◆ purge()
cache_disabled::purge |
( |
| ) |
|
Purges all items from the cache.
- Return values
-
Reimplemented from cache.
◆ requires_serialisation()
cache::requires_serialisation |
( |
|
$value, |
|
|
|
$depth = 1 |
|
) |
| |
|
protectedinherited |
Checks to see if a var requires serialisation.
- Parameters
-
mixed | $value | The value to check. |
int | $depth | Used to ensure we don't enter an endless loop (think recursion). |
- Return values
-
bool | Returns true if the value is going to require serialisation in order to ensure a reference free copy or false if its safe to clone. |
◆ set()
cache_disabled::set |
( |
|
$key, |
|
|
|
$data |
|
) |
| |
Sets a key value pair in the cache.
- Parameters
-
int | string | $key | Unused. |
mixed | $data | Unused. |
- Return values
-
Reimplemented from cache.
◆ set_data_source()
Set the data source for this cache.
- Parameters
-
◆ set_identifiers()
cache::set_identifiers |
( |
array |
$identifiers | ) |
|
|
inherited |
Alters the identifiers that have been provided to the definition.
This is an advanced method and should not be used unless really needed. It allows the developer to slightly alter the definition without having to re-establish the cache. It will cause more processing as the definition will need to clear and reprepare some of its properties.
- Parameters
-
◆ set_in_persist_cache()
cache::set_in_persist_cache |
( |
| ) |
|
|
protectedinherited |
◆ set_is_sub_loader()
cache::set_is_sub_loader |
( |
|
$setting = true | ) |
|
|
protectedinherited |
Used to inform the loader of its state as a sub loader, or as the top of the chain.
This is important as it ensures that we do not have more than one loader keeping static acceleration data. Subloaders need to be "pure" loaders in the sense that they are used to store and retrieve information from stores or the next loader/data source in the chain. Nothing fancy, nothing flash.
- Parameters
-
◆ set_loader()
Set the loader for this cache.
- Parameters
-
◆ set_many()
cache_disabled::set_many |
( |
array |
$keyvaluearray | ) |
|
Sets many key value pairs in the cache at once.
- Parameters
-
array | $keyvaluearray | Unused. |
- Return values
-
Reimplemented from cache.
◆ static_acceleration_delete()
cache::static_acceleration_delete |
( |
|
$key | ) |
|
|
protectedinherited |
Deletes an item from the static acceleration array.
- Parameters
-
string | int | $key | As given to get|set|delete |
- Return values
-
bool | True on success, false otherwise. |
◆ static_acceleration_get()
cache::static_acceleration_get |
( |
|
$key | ) |
|
|
protectedinherited |
Returns the item from the static acceleration array if it exists there.
- Parameters
-
- Return values
-
mixed|false | Dereferenced data from the static acceleration array or false if it wasn't there. |
◆ static_acceleration_has()
cache::static_acceleration_has |
( |
|
$key | ) |
|
|
protectedinherited |
Returns true if the requested key exists within the static acceleration array.
- Parameters
-
- Return values
-
◆ static_acceleration_set()
cache::static_acceleration_set |
( |
|
$key, |
|
|
|
$data |
|
) |
| |
|
protectedinherited |
Sets a key value pair into the static acceleration array.
- Parameters
-
string | $key | The parsed key |
mixed | $data | |
- Return values
-
◆ store_supports_key_awareness()
cache::store_supports_key_awareness |
( |
| ) |
|
|
protectedinherited |
Returns true if the store supports key awareness.
- Return values
-
◆ store_supports_native_locking()
cache::store_supports_native_locking |
( |
| ) |
|
|
protectedinherited |
Returns true if the store natively supports locking.
- Return values
-
◆ store_supports_native_ttl()
cache::store_supports_native_ttl |
( |
| ) |
|
|
protectedinherited |
Returns true if the cache store supports native ttl.
- Return values
-
◆ unref()
Removes references where required.
- Parameters
-
- Return values
-
mixed | What ever was put in but without any references. |
◆ use_static_acceleration()
cache::use_static_acceleration |
( |
| ) |
|
|
protectedinherited |
Returns true if this cache is making use of the static acceleration array.
- Return values
-
Reimplemented in cache_session.
◆ $now
We need a timestamp to use within the cache API.
This stamp needs to be used for all ttl and time based operations to ensure that we don't end up with timing issues.
◆ $purgetoken
string cache::$purgetoken |
|
staticprotectedinherited |
A purge token used to distinguish between multiple cache purges in the same second.
This is in the format <microtime>-<random string>.
◆ $storetype
strubg cache::$storetype = 'unknown' |
|
protectedinherited |
Gets set to the class name of the store during initialisation.
This is used several times in the cache class internally and having it here helps speed up processing.
The documentation for this class was generated from the following file: