\midcom_services_cache_module_nap

This is the NAP caching module. It provides the basic management functionality for the various backend databases which will be created based on the root topic of the NAP trees.

The actual handling of the various dbs is done with nav/backend.php, this class is responsible for the creation of backend instances and invalidation for NAP cache objects. (Which implies that it is fully aware of the data structures stored in the cache.)

All entries are indexed by their Midgard Object GUID. The entries in the NAP cache basically resemble the arrays within the NAP backend node/leaf cache

NAP caches can be shared over multiple sites, as all site specific data (like site prefixes) are evaluated during runtime.

Most of the cache update work is done in midcom_helper_nav_backend, so you should look there for details about the caching strategy.

Summary

Methods
Properties
Constants
initialize()
shutdown()
_on_initialize()
_on_shutdown()
invalidate_all()
invalidate()
get_node()
get_leaves()
put_node()
put_guid()
get_guid()
put_leaves()
No public properties found
No constants found
_create_backend()
$_backends
$_prefix
N/A
prepare_backend()
_load_from_guid()
$_cache
N/A

Properties

$_backends

$_backends : array<mixed,\Doctrine\Common\Cache\CacheProvider>

A list of all backends created by _create_backend(). They will be automatically shut down when the module shuts down. They are indexed by their name.

Type

array<mixed,\Doctrine\Common\Cache\CacheProvider>

$_prefix

$_prefix : string

The cache key prefix.

Type

string

$_cache

$_cache : \Doctrine\Common\Cache\CacheProvider

The cache backend instance to use.

Type

\Doctrine\Common\Cache\CacheProvider

Methods

initialize()

initialize() 

Initialize the module. This will initialize the class configuration and call the corresponding event handler.

shutdown()

shutdown() 

Shuts the module down. This will call the corresponding event handler

_on_initialize()

_on_initialize() 

Initialization event handler.

It will load the cache backends for the current MidCOM topic.

Initializes the backend configuration.

_on_shutdown()

_on_shutdown() 

Shutdown handler, called during midcom_application::finish(). Note, that for example the page cache will not use this cleanup handler, as it produces a complete html page based on a previous request.

invalidate_all()

invalidate_all() 

Invalidate the cache completely, dropping all entries. The default implementation will drop all entries from all registered cache backends using CacheProvider::flushAll().

Override this function if this behavior doesn't suit your needs.

invalidate()

invalidate(string  $guid, object  $object = null) 

Invalidate all cache objects related to the given GUID.

Parameters

string $guid

The GUID that has to be invalidated.

object $object

The object that has to be invalidated (if available).

get_node()

get_node(string  $key) : mixed

Looks up a node in the cache and returns it. Not existent keys are caught in this call as well, so you do not need to call exists first.

Parameters

string $key

The key to look up.

Returns

mixed —

The cached value on success, false on failure.

get_leaves()

get_leaves(string  $key) : mixed

Looks up a node in the cache and returns it. Not existent keys are caught in this call as well, so you do not need to call exists first.

Parameters

string $key

The key to look up.

Returns

mixed —

The cached value on success, false on failure.

put_node()

put_node(string  $key, mixed  $data, integer  $timeout = false) 

Sets a given node key in the cache.

Parameters

string $key

The key to look up.

mixed $data

The data to store.

integer $timeout

how long the data should live in the cache.

put_guid()

put_guid(string  $guid, mixed  $data, integer  $timeout = false) 

Save a given array by GUID in the cache.

Parameters

string $guid

The key to store.

mixed $data

The data to store.

integer $timeout

how long the data should live in the cache.

get_guid()

get_guid(string  $guid, integer  $timeout = false) 

Get a given array by GUID from the cache.

Parameters

string $guid

The key to look up.

integer $timeout

how long the data should live in the cache.

put_leaves()

put_leaves(string  $key, mixed  $data, integer  $timeout = false) 

Sets a given leave key in the cache

Parameters

string $key

The key to look up.

mixed $data

The data to store.

integer $timeout

how long the data should live in the cache.

_create_backend()

_create_backend(string  $name, array  $config) : \Doctrine\Common\Cache\CacheProvider

Creates an instance of the handler described by the configuration passed to the function.

The configuration array must include the configuration parameters driver and directory, as outlined in the midcom_services_cache_backend class documentation.

All backends will be collected in the $_backends array, indexed by their name.

Any duplicate instantiation will be intercepted, throwing a critical error.

Parameters

string $name

The name of the backend, must be unique throughout the system.

array $config

The configuration of the backend to create. It must contain the key 'driver', which indicates which backend to use.

Returns

\Doctrine\Common\Cache\CacheProvider —

The new backend.

prepare_backend()

prepare_backend(array  $config,   $name) 

Parameters

array $config
$name

_load_from_guid()

_load_from_guid(  $guid,   $object = null) 

Parameters

$guid
$object