The navigation_cache class is used for global and settings navigation data.
More...
|
| __construct ($area, $timeout=null) |
| Contructor for the cache.
|
|
| __get ($key) |
| Magic Method to retrieve a cached item by simply calling using = cache->key.
|
|
| __set ($key, $information) |
| Magic method that simply uses {.
|
|
| cached ($key) |
| Check the existence of the identifier in the cache.
|
|
| clear () |
| Deletes the entire cache area, forcing a fresh cache to be created.
|
|
| compare ($key, $value, $serialise=true) |
| Compare something to it's equivilant in the cache.
|
|
| set ($key, $information) |
| Sets some information in the session cache for later retrieval.
|
|
| volatile ($setting=true) |
| Marks the cache as volatile (likely to change)
|
|
|
int const | CACHETIME = 0 |
| cache time information
|
|
int const | CACHEUSERID = 1 |
| cache user id
|
|
int const | CACHEVALUE = 2 |
| cache value
|
|
|
static null array | $volatilecaches = null |
| An array of cache areas to expire on shutdown.
|
|
|
string | $area |
| A unique string to segregate this particular cache.
|
|
cache_session | $cache |
| The session cache instance.
|
|
array | $session = [] |
| The current cache area data.
|
|
The navigation_cache class is used for global and settings navigation data.
It provides an easy access to the session cache with TTL of 1800 seconds.
Example use: if (!$cache->viewdiscussion()) { // Code to do stuff and produce cachable content $cache->viewdiscussion = has_capability('mod/forum:viewdiscussion', $coursecontext); } $content = $cache->viewdiscussion;
- Copyright
- 2009 Sam Hemelryk
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
navigation_cache::__construct |
( |
| $area, |
|
|
| $timeout = null ) |
Contructor for the cache.
Requires a area string be passed in.
- Parameters
-
string | $area | The unique string to segregate this particular cache. |
int | $timeout | Deprecated since Moodle 4.5. The number of seconds to time the information out after |
◆ __get()
navigation_cache::__get |
( |
| $key | ) |
|
Magic Method to retrieve a cached item by simply calling using = cache->key.
- Parameters
-
mixed | $key | The identifier for the cached information |
- Return values
-
mixed|void | The cached information or void if not found |
◆ __set()
navigation_cache::__set |
( |
| $key, |
|
|
| $information ) |
Magic method that simply uses {.
- See also
- navigation_cache\set()} to store an item in the cache
- Parameters
-
string | int | $key | The key to store the information against |
mixed | $information | The information to cache |
◆ cached()
navigation_cache::cached |
( |
| $key | ) |
|
Check the existence of the identifier in the cache.
- Parameters
-
string | int | $key | The identifier to check |
- Return values
-
bool | True if the item exists in the cache, false otherwise |
◆ compare()
navigation_cache::compare |
( |
| $key, |
|
|
| $value, |
|
|
| $serialise = true ) |
Compare something to it's equivilant in the cache.
- Parameters
-
string | $key | The key to check |
mixed | $value | The value to compare |
bool | $serialise | Whether to serialise the value before comparison this should only be set to false if the value is already serialised |
- Return values
-
bool | True if the value is the same as the cached one, false otherwise |
◆ destroy_volatile_caches()
static navigation_cache::destroy_volatile_caches |
( |
| ) |
|
|
static |
Destroys all caches marked as volatile.
This function is static and works with the static volatilecaches property of navigation cache. It manually resets the cached areas back to an empty array.
◆ ensure_navigation_cache_initialised()
navigation_cache::ensure_navigation_cache_initialised |
( |
| ) |
|
|
protected |
Ensure the navigation cache is initialised.
This is called for each access and ensures that no data is put into the cache before it is required.
◆ set()
navigation_cache::set |
( |
| $key, |
|
|
| $information ) |
Sets some information in the session cache for later retrieval.
- Parameters
-
string | int | $key | |
mixed | $information | |
◆ volatile()
navigation_cache::volatile |
( |
| $setting = true | ) |
|
Marks the cache as volatile (likely to change)
Any caches marked as volatile will be destroyed on shutdown by {
- See also
- navigation_node::destroy_volatile_caches()}
- Parameters
-
bool | $setting | True to mark the cache as volatile, false to remove the volatile flag |
◆ $area
string navigation_cache::$area |
|
protected |
A unique string to segregate this particular cache.
It can either be unique to start a fresh cache or shared to use an existing cache.
The documentation for this class was generated from the following file: