\midcom_services_cache_module

This is the base class for the MidCOM cache modules. It provides a basic infrastructure for building your own caching service, providing hooks for initialization and shutdown.

It provides convenience methods to start up the cache module, for example for the creation of a cache backend instance. There is no specific initialization done during startup, to allow the modules to do their own magic during startup (it is difficult to generalize such stuff).

Summary

Methods
Properties
Constants
initialize()
shutdown()
_on_initialize()
_on_shutdown()
invalidate_all()
invalidate()
No public properties found
No constants found
_create_backend()
$_backends
$_prefix
N/A
prepare_backend()
No private properties found
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

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() 

Startup handler, called during service start up at the start of the request.

You may, as it is required for the content cache, intercept requests. Terminate the requests with _midcom_stop_request() if you produce a complete output based on a previous request (page cache) of midcom_application::finish() if you produce regular output that might go into the content cache.

_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).

_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