This class is the central access point for all registered caching services.

Currently this includes the NAP, Memcache, Content and PHPscripts cache databases.

The system is twofold:

There are cache backends, which are responsible for the actual storage and retrieval of cache information, and cache modules, which provide caching services to the application developer.

Check the documentation of the backends for configuring the cache on your live site (as an administrator).

Check the documentation of the cache modules to learn how to take advantage of the cache services available (as a component/core author).

The cache service is independent from the MidCOM Core, as it has to be started up at the beginning of the request. Cache modules are loaded on-demand.

This class will be available throughout he midcom service getter under the handle cache. The content cache module, for backwards compatibility, will be available as $midcom->cache.

All loaded modules will also be available as direct members of this class, you have to ensure the module is loaded in advance though. The class will automatically load all modules which are configured in the autoload_queue in the cache configuration.



__construct ()

Cache service startup.

It initializes all cache modules configured in the global configuration as outlined in the class introduction.

It will load the content cache module as the first one, the rest will be loaded in their order of appearance in the Array.

invalidate (mixed $guid, string $skip_module)

Invalidates all cache records associated with a given content object.



mixedThis is either a GUID or a MidgardObject, in which case the Guid is auto-dtermined.


stringIf specified, the module mentioned here is skipped during invalidation. This option should be avoided by component authors at all costs, it is there for optimizations within the core cache modules (which sometimes need to invalidate only other modules, and invalidate themselves implicitly).

invalidate_all ()

Invalidate all caches completely.

Use this, if you have, f.x. changes in the layout. The URL function midcom-cache-invalidate will trigger this function.

load_module (string $name)

This helper function will load the specified cache module (if not already loaded), add it to the _modules array and assign it to a member variable named after the module.



stringThe name of the cache module to load.

shutdown ()

Shuts all cache modules down.

The content module is explicitly stopped as the last module for clear content cache handling (it might _midcom_stop_request()).



Array $_modules

List of all loaded modules, indexed by their class name.

Array $_unload_queue

List of all modules in the order they need to be unloaded.

This is a FILO queue, the module loaded first is unloaded last.