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

package midcom.services

 Methods

_create_backend (string $name, array $config)

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

The backend instance returned should be assigned by reference, to avoid handle duplication or the like.

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.

access protected

Parameters

$name

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

$config

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

Returns

\midcom_services_cache_backendA reference to the new backend.

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

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.

initialize ()

Initialize the module.

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

invalidate (\GUID $guid)

Invalidate all cache objects related to the given GUID.

Parameters

$guid

\GUIDThe GUID that has to be invalidated.

invalidate_all ()

Invalidate the cache completely, dropping all entries.

The default implementation will drop all entries from all registered cache backends using midcom_services_cache_backend::remove_all(). Override this function, if this behavior doesn't suit your needs.

shutdown ()

Shuts the module down.

This will fist call the corresponding event handler, and will close all registered backends afterwards.

 Properties

 

Array $_backends

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.

access protected
 

Array $_config

Current configuration.
access protected