Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
navigation_cache Class Reference

Public Member Functions

 __construct ($area, $timeout=1800)
 Contructor for the cache. More...
 
 __get ($key)
 Magic Method to retrieve something by simply calling using = cache->key. More...
 
 __set ($key, $information)
 Magic method that simply uses set(); to store something in the cache. More...
 
 cached ($key)
 Check the existence of the identifier in the cache. More...
 
 clear ()
 Wipes the entire cache, good to force regeneration.
 
 compare ($key, $value, $serialise=true)
 Compare something to it's equivilant in the cache. More...
 
 set ($key, $information)
 Sets some information against the cache (session) for later retrieval. More...
 
 volatile ($setting=true)
 Marks the cache as being volatile (likely to change) More...
 

Static Public Member Functions

static destroy_volatile_caches ()
 Destroys all caches marked as volatile. More...
 

Public Attributes

int const CACHETIME = 0
 cache time information
 
int const CACHEUSERID = 1
 cache user id
 
int const CACHEVALUE = 2
 cache value
 

Static Public Attributes

static null array $volatilecaches
 An array of navigation cache areas to expire on shutdown.
 

Protected Member Functions

 ensure_session_cache_initialised ()
 Used to set up the cache within the SESSION. More...
 
 garbage_collection ()
 Checks all cache entries and removes any that have expired, good ole cleanup.
 

Protected Attributes

string $area
 The string to use to segregate this particular cache. More...
 
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
 

Constructor & Destructor Documentation

◆ __construct()

navigation_cache::__construct (   $area,
  $timeout = 1800 
)

Contructor for the cache.

Requires two arguments

Parameters
string$areaThe 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$timeoutThe number of seconds to time the information out after

Member Function Documentation

◆ __get()

navigation_cache::__get (   $key)

Magic Method to retrieve something by simply calling using = cache->key.

Parameters
mixed$keyThe identifier for the information you want out again
Return values
void|mixedEither 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
string | int$key
Return values
bool

◆ compare()

navigation_cache::compare (   $key,
  $value,
  $serialise = true 
)

Compare something to it's equivilant in the cache.

Parameters
string$key
mixed$value
bool$serialiseWhether to serialise the value before comparison this should only be set to false if the value is already serialised
Return values
boolIf 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$settingTrue to destroy the cache false not too

Member Data Documentation

◆ $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: