The cache class used by global navigation and settings navigation.
More...
|
| __construct ($area, $timeout=1800) |
| Contructor for the cache.
|
|
| __get ($key) |
| Magic Method to retrieve something by simply calling using = cache->key.
|
|
| __set ($key, $information) |
| Magic method that simply uses set(); to store something in the cache.
|
|
| cached ($key) |
| Check the existence of the identifier in the cache.
|
|
| clear () |
| Wipes the entire cache, good to force regeneration.
|
|
| compare ($key, $value, $serialise=true) |
| Compare something to it's equivilant in the cache.
|
|
| set ($key, $information) |
| Sets some information against the cache (session) for later retrieval.
|
|
| volatile ($setting=true) |
| Marks the cache as being 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 |
| An array of navigation cache areas to expire on shutdown.
|
|
|
| ensure_session_cache_initialised () |
| Used to set up the cache within the SESSION.
|
|
| garbage_collection () |
| Checks all cache entries and removes any that have expired, good ole cleanup.
|
|
|
string | $area |
| The string to use to segregate this particular cache.
|
|
int | $creation |
| represents the time created
|
|
stdClass | $currentcontext |
| The current context.
|
|
array | $session |
| An array of session keys.
|
|
int | $timeout |
| a time that the information will time out
|
|
The cache class used by global navigation and settings navigation.
It is basically an easy access point to session with a bit of smarts to make sure that the information that is cached is valid still.
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 = 1800 ) |
Contructor for the cache.
Requires two arguments
- Parameters
-
string | $area | The string to use to segregate this particular cache it can either be unique to start a fresh cache or if you want to share a cache then make it the string used in the original cache |
int | $timeout | The number of seconds to time the information out after |
◆ __get()
navigation_cache::__get |
( |
| $key | ) |
|
Magic Method to retrieve something by simply calling using = cache->key.
- Parameters
-
mixed | $key | The identifier for the information you want out again |
- Return values
-
void|mixed | Either void or what ever was put in |
◆ __set()
navigation_cache::__set |
( |
| $key, |
|
|
| $information ) |
Magic method that simply uses set(); to store something in the cache.
- Parameters
-
string | int | $key | |
mixed | $information | |
◆ cached()
navigation_cache::cached |
( |
| $key | ) |
|
Check the existence of the identifier in the cache.
- Parameters
-
- Return values
-
◆ compare()
navigation_cache::compare |
( |
| $key, |
|
|
| $value, |
|
|
| $serialise = true ) |
Compare something to it's equivilant in the cache.
- Parameters
-
string | $key | |
mixed | $value | |
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 | If the value is the same false if it is not set or doesn't match |
◆ destroy_volatile_caches()
static navigation_cache::destroy_volatile_caches |
( |
| ) |
|
|
static |
Destroys all caches marked as volatile.
This function is static and works in conjunction with the static volatilecaches property of navigation cache. Because this function is static it manually resets the cached areas back to an empty array.
◆ ensure_session_cache_initialised()
navigation_cache::ensure_session_cache_initialised |
( |
| ) |
|
|
protected |
Used to set up the cache within the SESSION.
This is called for each access and ensure that we don't put anything into the session before it is required.
◆ set()
navigation_cache::set |
( |
| $key, |
|
|
| $information ) |
Sets some information against the cache (session) for later retrieval.
- Parameters
-
string | int | $key | |
mixed | $information | |
◆ volatile()
navigation_cache::volatile |
( |
| $setting = true | ) |
|
Marks the cache as being volatile (likely to change)
Any caches marked as volatile will be destroyed at the on shutdown by navigation_node::destroy_volatile_caches() which is registered as a shutdown function if any caches are marked as volatile.
- Parameters
-
bool | $setting | True to destroy the cache false not too |
◆ $area
string navigation_cache::$area |
|
protected |
The string to use to segregate this particular cache.
It can either be unique to start a fresh cache or if you want to share a cache then make it the string used in the original cache.
The documentation for this class was generated from the following file: